Rich Felker | 0b44a03 | 2011-02-12 00:22:29 -0500 | [diff] [blame] | 1 | #ifndef _FCNTL_H |
| 2 | #define _FCNTL_H |
| 3 | |
| 4 | #ifdef __cplusplus |
| 5 | extern "C" { |
| 6 | #endif |
| 7 | |
Rich Felker | c1a9658 | 2012-09-07 23:13:55 -0400 | [diff] [blame] | 8 | #include <features.h> |
| 9 | |
Rich Felker | 0b44a03 | 2011-02-12 00:22:29 -0500 | [diff] [blame] | 10 | #define __NEED_off_t |
| 11 | #define __NEED_pid_t |
| 12 | #define __NEED_mode_t |
| 13 | |
Rich Felker | 53147f9 | 2012-07-23 16:50:56 -0400 | [diff] [blame] | 14 | #ifdef _GNU_SOURCE |
| 15 | #define __NEED_size_t |
| 16 | #define __NEED_ssize_t |
| 17 | #define __NEED_struct_iovec |
| 18 | #endif |
| 19 | |
Rich Felker | 0b44a03 | 2011-02-12 00:22:29 -0500 | [diff] [blame] | 20 | #include <bits/alltypes.h> |
| 21 | |
| 22 | #include <bits/fcntl.h> |
| 23 | |
| 24 | struct flock |
| 25 | { |
| 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 | |
Rich Felker | c2b18f3 | 2011-04-14 21:49:22 -0400 | [diff] [blame] | 40 | #define O_ACCMODE 03 |
| 41 | #define O_RDONLY 00 |
| 42 | #define O_WRONLY 01 |
| 43 | #define O_RDWR 02 |
| 44 | |
Rich Felker | 67b25fe | 2012-04-15 17:05:10 -0400 | [diff] [blame] | 45 | #define F_DUPFD_CLOEXEC 1030 |
| 46 | |
Rich Felker | c2b18f3 | 2011-04-14 21:49:22 -0400 | [diff] [blame] | 47 | #define F_RDLCK 0 |
| 48 | #define F_WRLCK 1 |
| 49 | #define F_UNLCK 2 |
| 50 | |
| 51 | #define FD_CLOEXEC 1 |
| 52 | |
| 53 | #define AT_FDCWD (-100) |
| 54 | #define AT_SYMLINK_NOFOLLOW 0x100 |
| 55 | #define AT_REMOVEDIR 0x200 |
| 56 | #define AT_SYMLINK_FOLLOW 0x400 |
| 57 | #define AT_EACCESS 0x200 |
| 58 | |
| 59 | #define POSIX_FADV_NORMAL 0 |
| 60 | #define POSIX_FADV_RANDOM 1 |
| 61 | #define POSIX_FADV_SEQUENTIAL 2 |
| 62 | #define POSIX_FADV_WILLNEED 3 |
| 63 | #define POSIX_FADV_DONTNEED 4 |
| 64 | #define POSIX_FADV_NOREUSE 5 |
| 65 | |
Rich Felker | 0b44a03 | 2011-02-12 00:22:29 -0500 | [diff] [blame] | 66 | #undef SEEK_SET |
| 67 | #undef SEEK_CUR |
| 68 | #undef SEEK_END |
| 69 | #define SEEK_SET 0 |
| 70 | #define SEEK_CUR 1 |
| 71 | #define SEEK_END 2 |
| 72 | |
Rich Felker | ac12eb9 | 2011-03-08 12:35:35 -0500 | [diff] [blame] | 73 | #ifndef S_IRUSR |
| 74 | #define S_ISUID 04000 |
| 75 | #define S_ISGID 02000 |
| 76 | #define S_ISVTX 01000 |
| 77 | #define S_IRUSR 0400 |
| 78 | #define S_IWUSR 0200 |
| 79 | #define S_IXUSR 0100 |
| 80 | #define S_IRWXU 0700 |
| 81 | #define S_IRGRP 0040 |
| 82 | #define S_IWGRP 0020 |
| 83 | #define S_IXGRP 0010 |
| 84 | #define S_IRWXG 0070 |
| 85 | #define S_IROTH 0004 |
| 86 | #define S_IWOTH 0002 |
| 87 | #define S_IXOTH 0001 |
| 88 | #define S_IRWXO 0007 |
| 89 | #endif |
| 90 | |
Rich Felker | 419ae6d | 2012-05-22 21:52:08 -0400 | [diff] [blame] | 91 | #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) |
Rich Felker | a3aa89d | 2011-04-14 22:06:30 -0400 | [diff] [blame] | 92 | #define FAPPEND O_APPEND |
| 93 | #define FFSYNC O_FSYNC |
| 94 | #define FASYNC O_ASYNC |
| 95 | #define FNONBLOCK O_NONBLOCK |
| 96 | #define FNDELAY O_NDELAY |
Rich Felker | 419ae6d | 2012-05-22 21:52:08 -0400 | [diff] [blame] | 97 | |
Rich Felker | 419ae6d | 2012-05-22 21:52:08 -0400 | [diff] [blame] | 98 | #define F_OK 0 |
| 99 | #define R_OK 4 |
| 100 | #define W_OK 2 |
| 101 | #define X_OK 1 |
| 102 | #define F_ULOCK 0 |
| 103 | #define F_LOCK 1 |
| 104 | #define F_TLOCK 2 |
| 105 | #define F_TEST 3 |
Rich Felker | 671ffab | 2012-05-22 22:04:55 -0400 | [diff] [blame] | 106 | |
Rich Felker | 419ae6d | 2012-05-22 21:52:08 -0400 | [diff] [blame] | 107 | int lockf(int, int, off_t); |
| 108 | #endif |
Rich Felker | a3aa89d | 2011-04-14 22:06:30 -0400 | [diff] [blame] | 109 | |
Rich Felker | 4e8b093 | 2012-06-20 22:16:47 -0400 | [diff] [blame] | 110 | #if defined(_GNU_SOURCE) |
| 111 | #define F_OWNER_TID 0 |
| 112 | #define F_OWNER_PID 1 |
| 113 | #define F_OWNER_PGRP 2 |
| 114 | #define F_OWNER_GID 2 |
| 115 | struct f_owner_ex { |
| 116 | int type; |
| 117 | pid_t pid; |
| 118 | }; |
Rich Felker | adb88e7 | 2012-09-08 00:33:04 -0400 | [diff] [blame] | 119 | #define FALLOC_FL_KEEP_SIZE 1 |
| 120 | #define FALLOC_FL_PUNCH_HOLE 2 |
Rich Felker | 00e6bbc | 2012-09-08 00:58:25 -0400 | [diff] [blame] | 121 | #define SYNC_FILE_RANGE_WAIT_BEFORE 1 |
| 122 | #define SYNC_FILE_RANGE_WRITE 2 |
| 123 | #define SYNC_FILE_RANGE_WAIT_AFTER 4 |
Rich Felker | 53147f9 | 2012-07-23 16:50:56 -0400 | [diff] [blame] | 124 | #define SPLICE_F_MOVE 1 |
| 125 | #define SPLICE_F_NONBLOCK 2 |
| 126 | #define SPLICE_F_MORE 4 |
| 127 | #define SPLICE_F_GIFT 8 |
Rich Felker | adb88e7 | 2012-09-08 00:33:04 -0400 | [diff] [blame] | 128 | int fallocate(int, int, off_t, off_t); |
Rich Felker | 90f7705 | 2012-09-08 00:40:37 -0400 | [diff] [blame] | 129 | ssize_t readahead(int, off_t, size_t); |
Rich Felker | 00e6bbc | 2012-09-08 00:58:25 -0400 | [diff] [blame] | 130 | int sync_file_range(int, off_t, off_t, unsigned); |
Rich Felker | 53147f9 | 2012-07-23 16:50:56 -0400 | [diff] [blame] | 131 | ssize_t vmsplice(int, const struct iovec *, size_t, unsigned); |
| 132 | ssize_t splice(int, off_t *, int, off_t *, size_t, unsigned); |
Rich Felker | 997ba92 | 2012-09-08 01:03:01 -0400 | [diff] [blame] | 133 | ssize_t tee(int, int, size_t, unsigned); |
Rich Felker | c4ea0e3 | 2012-09-06 23:49:44 -0400 | [diff] [blame] | 134 | #define loff_t off_t |
Rich Felker | 4e8b093 | 2012-06-20 22:16:47 -0400 | [diff] [blame] | 135 | #endif |
| 136 | |
Rich Felker | 3b94dab | 2012-06-04 08:03:56 -0400 | [diff] [blame] | 137 | #if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE) |
Rich Felker | 2dd8d5e | 2012-05-04 00:13:23 -0400 | [diff] [blame] | 138 | #define open64 open |
| 139 | #define openat64 openat |
| 140 | #define creat64 creat |
| 141 | #define lockf64 lockf |
| 142 | #define posix_fadvise64 posix_fadvise |
| 143 | #define posix_fallocate64 posix_fallocate |
| 144 | #define off64_t off_t |
| 145 | #endif |
| 146 | |
Rich Felker | 0b44a03 | 2011-02-12 00:22:29 -0500 | [diff] [blame] | 147 | #ifdef __cplusplus |
| 148 | } |
| 149 | #endif |
| 150 | |
| 151 | #endif |