fcntl.h 4.6 KB

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