b39ba9cd4573d156cbb238bbdb38103aa55490f0
[reactos.git] / posix / include / fcntl.h
1 /* $Id: fcntl.h,v 1.2 2002/02/20 09:17:54 hyperion Exp $
2 */
3 /*
4 * fcntl.h
5 *
6 * file control options. Conforming to the Single UNIX(r) Specification
7 * Version 2, System Interface & Headers Issue 5
8 *
9 * This file is part of the ReactOS Operating System.
10 *
11 * Contributors:
12 * Created by KJK::Hyperion <noog@libero.it>
13 *
14 * THIS SOFTWARE IS NOT COPYRIGHTED
15 *
16 * This source code is offered for use in the public domain. You may
17 * use, modify or distribute it freely.
18 *
19 * This code is distributed in the hope that it will be useful but
20 * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
21 * DISCLAMED. This includes but is not limited to warranties of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
23 *
24 */
25 #ifndef __FCNTL_H_INCLUDED__
26 #define __FCNTL_H_INCLUDED__
27
28 /* INCLUDES */
29 #include <sys/stat.h>
30 #include <sys/types.h>
31 #include <unistd.h>
32
33 /* OBJECTS */
34
35 /* TYPES */
36 /*
37 the structure flock describes a file lock
38 */
39 struct flock
40 {
41 short l_type; /* type of lock; F_RDLCK, F_WRLCK, F_UNLCK */
42 short l_whence; /* flag for starting offset */
43 off_t l_start; /* relative offset in bytes */
44 off_t l_len; /* size; if 0 then until EOF */
45 pid_t l_pid; /* process ID of the process holding the lock;
46 returned with F_GETLK */
47 };
48
49 /* CONSTANTS */
50 /*
51 values for cmd used by fcntl()
52 */
53 enum __fcntl_cmd
54 {
55 F_DUPFD, /* duplicate file descriptor */
56 F_GETFD, /* get file descriptor flags */
57 F_SETFD, /* set file descriptor flags */
58 F_GETFL, /* get file status flags and file access modes */
59 F_SETFL, /* Set file status flags */
60 F_GETLK, /* get record locking information */
61 F_SETLK, /* set record locking information */
62 F_SETLKW, /* set record locking information; wait if blocked */
63 /* ReactOS-specific */
64 F_NEWFD, /* create new file descriptor */
65 F_DELFD, /* delete file descriptor */
66 F_GETALL, /* get a copy of the internal descriptor object */
67 F_SETALL, /* initialize internal descriptor object */
68 F_GETXP, /* get file descriptor extra data pointer */
69 F_SETXP, /* set file descriptor extra data pointer */
70 F_GETXS, /* get file descriptor extra data size */
71 F_SETXS, /* set file descriptor extra data size */
72 F_GETFH, /* get file handle */
73 F_SETFH /* set file handle */
74 };
75
76 /*
77 file descriptor flags used for fcntl()
78 */
79 /* Close the file descriptor upon execution of an exec family function. */
80 #define FD_CLOEXEC (0x00000001)
81
82 /*
83 values for l_type used for record locking with fcntl()
84 */
85 /* Shared or read lock. */
86 #define F_RDLCK (1)
87 /* Unlock. */
88 #define F_UNLCK (2)
89 /* Exclusive or write lock. */
90 #define F_WRLCK (3)
91
92 /*
93 file flags used for open()
94 */
95 /* Create file if it does not exist. */
96 #define O_CREAT (0x00000001)
97 /* Exclusive use flag. */
98 #define O_EXCL (0x00000002)
99 /* Do not assign controlling terminal. */
100 #define O_NOCTTY (0x00000004)
101 /* Truncate flag. */
102 #define O_TRUNC (0x00000008)
103 /* ReactOS-specific */
104 /* File must be a directory */
105 #define _O_DIRFILE (0x00000010)
106
107 /*
108 file status flags used for open() and fcntl()
109 */
110 /* Set append mode. */
111 #define O_APPEND (0x00000100)
112 /* Write according to synchronised I/O data integrity completion. */
113 #define O_DSYNC (0x00000200)
114 /* Non-blocking mode. */
115 #define O_NONBLOCK (0x00000400)
116 /* Synchronised read I/O operations. */
117 #define O_RSYNC (0x00000800)
118 /* Write according to synchronised I/O file integrity completion. */
119 #define O_SYNC (0x00001000)
120
121 /*
122 file access modes used for open() and fcntl()
123 */
124 /* Open for reading only. */
125 #define O_RDONLY (0x01000000)
126 /* Open for reading and writing. */
127 #define O_RDWR (0x02000000)
128 /* Open for writing only. */
129 #define O_WRONLY (0x04000000)
130
131 /*
132 mask for use with file access modes
133 */
134 #define O_ACCMODE (O_RDONLY | O_RDWR | O_WRONLY)
135
136 /* PROTOTYPES */
137 int creat(const char *, mode_t);
138 int fcntl(int, int, ...);
139 int open(const char *, int, ...);
140
141 int _Wcreat(const wchar_t *, mode_t);
142 int _Wopen(const wchar_t *, int, ...);
143
144 /* MACROS */
145
146 #endif /* __FCNTL_H_INCLUDED__ */
147
148 /* EOF */
149