fcntl.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. #ifndef _ASM_GENERIC_FCNTL_H
  2. #define _ASM_GENERIC_FCNTL_H
  3. #include <linux/types.h>
  4. /*
  5. * FMODE_EXEC is 0x20
  6. * FMODE_NONOTIFY is 0x800000
  7. * These cannot be used by userspace O_* until internal and external open
  8. * flags are split.
  9. * -Eric Paris
  10. */
  11. #define O_ACCMODE 00000003
  12. #define O_RDONLY 00000000
  13. #define O_WRONLY 00000001
  14. #define O_RDWR 00000002
  15. #ifndef O_CREAT
  16. #define O_CREAT 00000100 /* not fcntl */
  17. #endif
  18. #ifndef O_EXCL
  19. #define O_EXCL 00000200 /* not fcntl */
  20. #endif
  21. #ifndef O_NOCTTY
  22. #define O_NOCTTY 00000400 /* not fcntl */
  23. #endif
  24. #ifndef O_TRUNC
  25. #define O_TRUNC 00001000 /* not fcntl */
  26. #endif
  27. #ifndef O_APPEND
  28. #define O_APPEND 00002000
  29. #endif
  30. #ifndef O_NONBLOCK
  31. #define O_NONBLOCK 00004000
  32. #endif
  33. #ifndef O_DSYNC
  34. #define O_DSYNC 00010000 /* used to be O_SYNC, see below */
  35. #endif
  36. #ifndef FASYNC
  37. #define FASYNC 00020000 /* fcntl, for BSD compatibility */
  38. #endif
  39. #ifndef O_DIRECT
  40. #define O_DIRECT 00040000 /* direct disk access hint */
  41. #endif
  42. #ifndef O_LARGEFILE
  43. #define O_LARGEFILE 00100000
  44. #endif
  45. #ifndef O_DIRECTORY
  46. #define O_DIRECTORY 00200000 /* must be a directory */
  47. #endif
  48. #ifndef O_NOFOLLOW
  49. #define O_NOFOLLOW 00400000 /* don't follow links */
  50. #endif
  51. #ifndef O_NOATIME
  52. #define O_NOATIME 01000000
  53. #endif
  54. #ifndef O_CLOEXEC
  55. #define O_CLOEXEC 02000000 /* set close_on_exec */
  56. #endif
  57. /*
  58. * Before Linux 2.6.33 only O_DSYNC semantics were implemented, but using
  59. * the O_SYNC flag. We continue to use the existing numerical value
  60. * for O_DSYNC semantics now, but using the correct symbolic name for it.
  61. * This new value is used to request true Posix O_SYNC semantics. It is
  62. * defined in this strange way to make sure applications compiled against
  63. * new headers get at least O_DSYNC semantics on older kernels.
  64. *
  65. * This has the nice side-effect that we can simply test for O_DSYNC
  66. * wherever we do not care if O_DSYNC or O_SYNC is used.
  67. *
  68. * Note: __O_SYNC must never be used directly.
  69. */
  70. #ifndef O_SYNC
  71. #define __O_SYNC 04000000
  72. #define O_SYNC (__O_SYNC|O_DSYNC)
  73. #endif
  74. #ifndef O_NDELAY
  75. #define O_NDELAY O_NONBLOCK
  76. #endif
  77. #define F_DUPFD 0 /* dup */
  78. #define F_GETFD 1 /* get close_on_exec */
  79. #define F_SETFD 2 /* set/clear close_on_exec */
  80. #define F_GETFL 3 /* get file->f_flags */
  81. #define F_SETFL 4 /* set file->f_flags */
  82. #ifndef F_GETLK
  83. #define F_GETLK 5
  84. #define F_SETLK 6
  85. #define F_SETLKW 7
  86. #endif
  87. #ifndef F_SETOWN
  88. #define F_SETOWN 8 /* for sockets. */
  89. #define F_GETOWN 9 /* for sockets. */
  90. #endif
  91. #ifndef F_SETSIG
  92. #define F_SETSIG 10 /* for sockets. */
  93. #define F_GETSIG 11 /* for sockets. */
  94. #endif
  95. #ifndef CONFIG_64BIT
  96. #ifndef F_GETLK64
  97. #define F_GETLK64 12 /* using 'struct flock64' */
  98. #define F_SETLK64 13
  99. #define F_SETLKW64 14
  100. #endif
  101. #endif
  102. #ifndef F_SETOWN_EX
  103. #define F_SETOWN_EX 15
  104. #define F_GETOWN_EX 16
  105. #endif
  106. #define F_OWNER_TID 0
  107. #define F_OWNER_PID 1
  108. #define F_OWNER_PGRP 2
  109. struct f_owner_ex {
  110. int type;
  111. pid_t pid;
  112. };
  113. /* for F_[GET|SET]FL */
  114. #define FD_CLOEXEC 1 /* actually anything with low bit set goes */
  115. /* for posix fcntl() and lockf() */
  116. #ifndef F_RDLCK
  117. #define F_RDLCK 0
  118. #define F_WRLCK 1
  119. #define F_UNLCK 2
  120. #endif
  121. /* for old implementation of bsd flock () */
  122. #ifndef F_EXLCK
  123. #define F_EXLCK 4 /* or 3 */
  124. #define F_SHLCK 8 /* or 4 */
  125. #endif
  126. /* for leases */
  127. #ifndef F_INPROGRESS
  128. #define F_INPROGRESS 16
  129. #endif
  130. /* operations for bsd flock(), also used by the kernel implementation */
  131. #define LOCK_SH 1 /* shared lock */
  132. #define LOCK_EX 2 /* exclusive lock */
  133. #define LOCK_NB 4 /* or'd with one of the above to prevent
  134. blocking */
  135. #define LOCK_UN 8 /* remove lock */
  136. #define LOCK_MAND 32 /* This is a mandatory flock ... */
  137. #define LOCK_READ 64 /* which allows concurrent read operations */
  138. #define LOCK_WRITE 128 /* which allows concurrent write operations */
  139. #define LOCK_RW 192 /* which allows concurrent read & write ops */
  140. #define F_LINUX_SPECIFIC_BASE 1024
  141. #ifndef HAVE_ARCH_STRUCT_FLOCK
  142. #ifndef __ARCH_FLOCK_PAD
  143. #define __ARCH_FLOCK_PAD
  144. #endif
  145. struct flock {
  146. short l_type;
  147. short l_whence;
  148. __kernel_off_t l_start;
  149. __kernel_off_t l_len;
  150. __kernel_pid_t l_pid;
  151. __ARCH_FLOCK_PAD
  152. };
  153. #endif
  154. #ifndef CONFIG_64BIT
  155. #ifndef HAVE_ARCH_STRUCT_FLOCK64
  156. #ifndef __ARCH_FLOCK64_PAD
  157. #define __ARCH_FLOCK64_PAD
  158. #endif
  159. struct flock64 {
  160. short l_type;
  161. short l_whence;
  162. __kernel_loff_t l_start;
  163. __kernel_loff_t l_len;
  164. __kernel_pid_t l_pid;
  165. __ARCH_FLOCK64_PAD
  166. };
  167. #endif
  168. #endif /* !CONFIG_64BIT */
  169. #endif /* _ASM_GENERIC_FCNTL_H */