fcntl.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  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_ACCMODE (03|O_SEARCH)
  33. #define O_RDONLY 00
  34. #define O_WRONLY 01
  35. #define O_RDWR 02
  36. #define F_OFD_GETLK 36
  37. #define F_OFD_SETLK 37
  38. #define F_OFD_SETLKW 38
  39. #define F_DUPFD_CLOEXEC 1030
  40. #define F_RDLCK 0
  41. #define F_WRLCK 1
  42. #define F_UNLCK 2
  43. #define FD_CLOEXEC 1
  44. #define AT_FDCWD (-100)
  45. #define AT_SYMLINK_NOFOLLOW 0x100
  46. #define AT_REMOVEDIR 0x200
  47. #define AT_SYMLINK_FOLLOW 0x400
  48. #define AT_EACCESS 0x200
  49. #define POSIX_FADV_NORMAL 0
  50. #define POSIX_FADV_RANDOM 1
  51. #define POSIX_FADV_SEQUENTIAL 2
  52. #define POSIX_FADV_WILLNEED 3
  53. #define POSIX_FADV_DONTNEED 4
  54. #define POSIX_FADV_NOREUSE 5
  55. #undef SEEK_SET
  56. #undef SEEK_CUR
  57. #undef SEEK_END
  58. #define SEEK_SET 0
  59. #define SEEK_CUR 1
  60. #define SEEK_END 2
  61. #ifndef S_IRUSR
  62. #define S_ISUID 04000
  63. #define S_ISGID 02000
  64. #define S_ISVTX 01000
  65. #define S_IRUSR 0400
  66. #define S_IWUSR 0200
  67. #define S_IXUSR 0100
  68. #define S_IRWXU 0700
  69. #define S_IRGRP 0040
  70. #define S_IWGRP 0020
  71. #define S_IXGRP 0010
  72. #define S_IRWXG 0070
  73. #define S_IROTH 0004
  74. #define S_IWOTH 0002
  75. #define S_IXOTH 0001
  76. #define S_IRWXO 0007
  77. #endif
  78. #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
  79. #define AT_NO_AUTOMOUNT 0x800
  80. #define AT_EMPTY_PATH 0x1000
  81. #define FAPPEND O_APPEND
  82. #define FFSYNC O_FSYNC
  83. #define FASYNC O_ASYNC
  84. #define FNONBLOCK O_NONBLOCK
  85. #define FNDELAY O_NDELAY
  86. #define F_OK 0
  87. #define R_OK 4
  88. #define W_OK 2
  89. #define X_OK 1
  90. #define F_ULOCK 0
  91. #define F_LOCK 1
  92. #define F_TLOCK 2
  93. #define F_TEST 3
  94. #define F_SETLEASE 1024
  95. #define F_GETLEASE 1025
  96. #define F_NOTIFY 1026
  97. #define F_CANCELLK 1029
  98. #define F_SETPIPE_SZ 1031
  99. #define F_GETPIPE_SZ 1032
  100. #define F_ADD_SEALS 1033
  101. #define F_GET_SEALS 1034
  102. #define F_SEAL_SEAL 0x0001
  103. #define F_SEAL_SHRINK 0x0002
  104. #define F_SEAL_GROW 0x0004
  105. #define F_SEAL_WRITE 0x0008
  106. #define DN_ACCESS 0x00000001
  107. #define DN_MODIFY 0x00000002
  108. #define DN_CREATE 0x00000004
  109. #define DN_DELETE 0x00000008
  110. #define DN_RENAME 0x00000010
  111. #define DN_ATTRIB 0x00000020
  112. #define DN_MULTISHOT 0x80000000
  113. int lockf(int, int, off_t);
  114. #endif
  115. #if defined(_GNU_SOURCE)
  116. #define F_OWNER_TID 0
  117. #define F_OWNER_PID 1
  118. #define F_OWNER_PGRP 2
  119. #define F_OWNER_GID 2
  120. struct f_owner_ex {
  121. int type;
  122. pid_t pid;
  123. };
  124. #define FALLOC_FL_KEEP_SIZE 1
  125. #define FALLOC_FL_PUNCH_HOLE 2
  126. #define SYNC_FILE_RANGE_WAIT_BEFORE 1
  127. #define SYNC_FILE_RANGE_WRITE 2
  128. #define SYNC_FILE_RANGE_WAIT_AFTER 4
  129. #define SPLICE_F_MOVE 1
  130. #define SPLICE_F_NONBLOCK 2
  131. #define SPLICE_F_MORE 4
  132. #define SPLICE_F_GIFT 8
  133. int fallocate(int, int, off_t, off_t);
  134. #define fallocate64 fallocate
  135. ssize_t readahead(int, off_t, size_t);
  136. int sync_file_range(int, off_t, off_t, unsigned);
  137. ssize_t vmsplice(int, const struct iovec *, size_t, unsigned);
  138. ssize_t splice(int, off_t *, int, off_t *, size_t, unsigned);
  139. ssize_t tee(int, int, size_t, unsigned);
  140. #define loff_t off_t
  141. #endif
  142. #if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE)
  143. #define F_GETLK64 F_GETLK
  144. #define F_SETLK64 F_SETLK
  145. #define F_SETLKW64 F_SETLKW
  146. #define flock64 flock
  147. #define open64 open
  148. #define openat64 openat
  149. #define creat64 creat
  150. #define lockf64 lockf
  151. #define posix_fadvise64 posix_fadvise
  152. #define posix_fallocate64 posix_fallocate
  153. #define off64_t off_t
  154. #endif
  155. #ifdef __cplusplus
  156. }
  157. #endif
  158. #endif