xref: /haiku/headers/private/fs_shell/fssh_fcntl.h (revision aec945c95934ada0d7fda53b1d075a5c40c7a37a)
1 /*
2  * Copyright 2002-2007, Haiku Inc. All Rights Reserved.
3  * Distributed under the terms of the MIT License.
4  */
5 #ifndef _FSSH_FCNTL_H
6 #define _FSSH_FCNTL_H
7 
8 
9 #include "fssh_types.h"
10 
11 
12 /* commands that can be passed to fcntl() */
13 #define	FSSH_F_DUPFD		0x0001		/* duplicate fd */
14 #define	FSSH_F_GETFD		0x0002		/* get fd flags */
15 #define	FSSH_F_SETFD		0x0004		/* set fd flags */
16 #define	FSSH_F_GETFL		0x0008		/* get file status flags and access mode */
17 #define	FSSH_F_SETFL		0x0010		/* set file status flags */
18 #define FSSH_F_GETLK		0x0020		/* get locking information */
19 #define FSSH_F_SETLK		0x0080		/* set locking information */
20 #define FSSH_F_SETLKW		0x0100		/* as above, but waits if blocked */
21 
22 /* advisory locking types */
23 #define FSSH_F_RDLCK		0x0040		/* read or shared lock */
24 #define FSSH_F_UNLCK		0x0200		/* unlock */
25 #define FSSH_F_WRLCK		0x0400		/* write or exclusive lock */
26 
27 /* file descriptor flags for fcntl() */
28 #define FSSH_FD_CLOEXEC		1			/* close on exec */
29 
30 /* file access modes for open() */
31 #define FSSH_O_RDONLY		0x0000		/* read only */
32 #define FSSH_O_WRONLY		0x0001		/* write only */
33 #define FSSH_O_RDWR			0x0002		/* read and write */
34 #define FSSH_O_ACCMODE   	0x0003		/* mask to get the access modes above */
35 #define FSSH_O_RWMASK		FSSH_O_ACCMODE
36 
37 /* flags for open() */
38 #define	FSSH_O_EXCL			0x0100		/* exclusive creat */
39 #define FSSH_O_CREAT		0x0200		/* create and open file */
40 #define FSSH_O_TRUNC		0x0400		/* open with truncation */
41 #define FSSH_O_NOCTTY		0x1000		/* currently unsupported */
42 #define	FSSH_O_NOTRAVERSE	0x2000		/* do not traverse leaf link */
43 
44 /* flags for open() and fcntl() */
45 #define FSSH_O_CLOEXEC		0x00000040	/* close on exec */
46 #define	FSSH_O_NONBLOCK		0x00000080	/* non blocking io */
47 #define FSSH_O_APPEND		0x00000800	/* to end of file */
48 #define FSSH_O_TEXT			0x00004000	/* CR-LF translation */
49 #define FSSH_O_BINARY		0x00008000	/* no translation */
50 #define FSSH_O_SYNC			0x00010000	/* write synchronized I/O file integrity */
51 #define FSSH_O_RSYNC		0x00020000	/* read synchronized I/O file integrity */
52 #define FSSH_O_DSYNC		0x00040000	/* write synchronized I/O data integrity */
53 #define FSSH_O_NOFOLLOW		0x00080000	/* fail on symlinks */
54 #define FSSH_O_NOCACHE		0x00100000	/* do not use the file system cache if */
55 										/* possible */
56 #define FSSH_O_DIRECT		FSSH_O_NOCACHE
57 #define FSSH_O_DIRECTORY	0x00200000	/* fail if not a directory */
58 
59 // TODO: currently not implemented additions:
60 	/* should we implement this? it's similar to O_NOTRAVERSE but will fail on symlinks */
61 #define FSSH_O_TEMPORARY	0x00400000	/* used to avoid writing temporary files to disk */
62 
63 #define FSSH_S_IREAD		0x0100  /* owner may read */
64 #define FSSH_S_IWRITE		0x0080	/* owner may write */
65 
66 
67 #ifdef __cplusplus
68 extern "C" {
69 #endif
70 
71 extern int	fssh_creat(const char *path, fssh_mode_t mode);
72 extern int	fssh_open(const char *pathname, int oflags, ...);
73 	/* the third argument is the permissions of the created file when O_CREAT
74 	   is passed in oflags */
75 
76 extern int	fssh_fcntl(int fd, int op, ...);
77 
78 #ifdef __cplusplus
79 }
80 #endif
81 
82 #endif /* _FSSH_FCNTL_H */
83