1 #ifndef _FCNTL_H 2 #define _FCNTL_H 3 4 #ifdef __cplusplus 5 extern "C" { 6 #endif 7 8 #include <features.h> 9 10 #define __NEED_off_t 11 #define __NEED_pid_t 12 #define __NEED_mode_t 13 14 #ifdef _GNU_SOURCE 15 #define __NEED_size_t 16 #define __NEED_ssize_t 17 #define __NEED_struct_iovec 18 #endif 19 20 #include <bits/alltypes.h> 21 22 #include <bits/fcntl.h> 23 #include <fortify/fcntl.h> 24 25 struct flock { 26 short l_type; 27 short l_whence; 28 off_t l_start; 29 off_t l_len; 30 pid_t l_pid; 31 }; 32 33 int creat(const char *, mode_t); 34 int fcntl(int, int, ...); 35 int open(const char *, int, ...); 36 int openat(int, const char *, int, ...); 37 int posix_fadvise(int, off_t, off_t, int); 38 int posix_fallocate(int, off_t, off_t); 39 40 #define O_SEARCH O_PATH 41 #define O_EXEC O_PATH 42 #define O_TTY_INIT 0 43 44 #define O_ACCMODE (03|O_SEARCH) 45 #define O_RDONLY 00 46 #define O_WRONLY 01 47 #define O_RDWR 02 48 49 #define F_OFD_GETLK 36 50 #define F_OFD_SETLK 37 51 #define F_OFD_SETLKW 38 52 53 #define F_DUPFD_CLOEXEC 1030 54 55 #define F_RDLCK 0 56 #define F_WRLCK 1 57 #define F_UNLCK 2 58 59 #define FD_CLOEXEC 1 60 61 #define AT_FDCWD (-100) 62 #define AT_SYMLINK_NOFOLLOW 0x100 63 #define AT_REMOVEDIR 0x200 64 #define AT_SYMLINK_FOLLOW 0x400 65 #define AT_EACCESS 0x200 66 67 #define POSIX_FADV_NORMAL 0 68 #define POSIX_FADV_RANDOM 1 69 #define POSIX_FADV_SEQUENTIAL 2 70 #define POSIX_FADV_WILLNEED 3 71 #ifndef POSIX_FADV_DONTNEED 72 #define POSIX_FADV_DONTNEED 4 73 #define POSIX_FADV_NOREUSE 5 74 #endif 75 76 #undef SEEK_SET 77 #undef SEEK_CUR 78 #undef SEEK_END 79 #define SEEK_SET 0 80 #define SEEK_CUR 1 81 #define SEEK_END 2 82 83 #ifndef S_IRUSR 84 #define S_ISUID 04000 85 #define S_ISGID 02000 86 #define S_ISVTX 01000 87 #define S_IRUSR 0400 88 #define S_IWUSR 0200 89 #define S_IXUSR 0100 90 #define S_IRWXU 0700 91 #define S_IRGRP 0040 92 #define S_IWGRP 0020 93 #define S_IXGRP 0010 94 #define S_IRWXG 0070 95 #define S_IROTH 0004 96 #define S_IWOTH 0002 97 #define S_IXOTH 0001 98 #define S_IRWXO 0007 99 #endif 100 101 #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) 102 #define AT_NO_AUTOMOUNT 0x800 103 #define AT_EMPTY_PATH 0x1000 104 #define AT_STATX_SYNC_TYPE 0x6000 105 #define AT_STATX_SYNC_AS_STAT 0x0000 106 #define AT_STATX_FORCE_SYNC 0x2000 107 #define AT_STATX_DONT_SYNC 0x4000 108 #define AT_RECURSIVE 0x8000 109 110 #define FAPPEND O_APPEND 111 #define FFSYNC O_SYNC 112 #define FASYNC O_ASYNC 113 #define FNONBLOCK O_NONBLOCK 114 #define FNDELAY O_NDELAY 115 116 #define F_OK 0 117 #define R_OK 4 118 #define W_OK 2 119 #define X_OK 1 120 #define F_ULOCK 0 121 #define F_LOCK 1 122 #define F_TLOCK 2 123 #define F_TEST 3 124 125 #define F_SETLEASE 1024 126 #define F_GETLEASE 1025 127 #define F_NOTIFY 1026 128 #define F_CANCELLK 1029 129 #define F_SETPIPE_SZ 1031 130 #define F_GETPIPE_SZ 1032 131 #define F_ADD_SEALS 1033 132 #define F_GET_SEALS 1034 133 134 #define F_SEAL_SEAL 0x0001 135 #define F_SEAL_SHRINK 0x0002 136 #define F_SEAL_GROW 0x0004 137 #define F_SEAL_WRITE 0x0008 138 #define F_SEAL_FUTURE_WRITE 0x0010 139 140 #define F_GET_RW_HINT 1035 141 #define F_SET_RW_HINT 1036 142 #define F_GET_FILE_RW_HINT 1037 143 #define F_SET_FILE_RW_HINT 1038 144 145 #define RWF_WRITE_LIFE_NOT_SET 0 146 #define RWH_WRITE_LIFE_NONE 1 147 #define RWH_WRITE_LIFE_SHORT 2 148 #define RWH_WRITE_LIFE_MEDIUM 3 149 #define RWH_WRITE_LIFE_LONG 4 150 #define RWH_WRITE_LIFE_EXTREME 5 151 152 #define DN_ACCESS 0x00000001 153 #define DN_MODIFY 0x00000002 154 #define DN_CREATE 0x00000004 155 #define DN_DELETE 0x00000008 156 #define DN_RENAME 0x00000010 157 #define DN_ATTRIB 0x00000020 158 #define DN_MULTISHOT 0x80000000 159 160 int lockf(int, int, off_t); 161 #endif 162 163 #if defined(_GNU_SOURCE) 164 #define F_OWNER_TID 0 165 #define F_OWNER_PID 1 166 #define F_OWNER_PGRP 2 167 #define F_OWNER_GID 2 168 struct file_handle { 169 unsigned handle_bytes; 170 int handle_type; 171 unsigned char f_handle[]; 172 }; 173 struct f_owner_ex { 174 int type; 175 pid_t pid; 176 }; 177 #define FALLOC_FL_KEEP_SIZE 1 178 #define FALLOC_FL_PUNCH_HOLE 2 179 #define MAX_HANDLE_SZ 128 180 #define SYNC_FILE_RANGE_WAIT_BEFORE 1 181 #define SYNC_FILE_RANGE_WRITE 2 182 #define SYNC_FILE_RANGE_WAIT_AFTER 4 183 #define SPLICE_F_MOVE 1 184 #define SPLICE_F_NONBLOCK 2 185 #define SPLICE_F_MORE 4 186 #define SPLICE_F_GIFT 8 187 int fallocate(int, int, off_t, off_t); 188 #define fallocate64 fallocate 189 int name_to_handle_at(int, const char *, struct file_handle *, int *, int); 190 int open_by_handle_at(int, struct file_handle *, int); 191 ssize_t readahead(int, off_t, size_t); 192 int sync_file_range(int, off_t, off_t, unsigned); 193 ssize_t vmsplice(int, const struct iovec *, size_t, unsigned); 194 ssize_t splice(int, off_t *, int, off_t *, size_t, unsigned); 195 ssize_t tee(int, int, size_t, unsigned); 196 #define loff_t off_t 197 #endif 198 199 #if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE) 200 #define F_GETLK64 F_GETLK 201 #define F_SETLK64 F_SETLK 202 #define F_SETLKW64 F_SETLKW 203 #define flock64 flock 204 #define open64 open 205 #define openat64 openat 206 #define creat64 creat 207 #define lockf64 lockf 208 #define posix_fadvise64 posix_fadvise 209 #define posix_fallocate64 posix_fallocate 210 #define off64_t off_t 211 #endif 212 213 #ifdef __cplusplus 214 } 215 #endif 216 217 #endif 218