fcntl.h 4.2 KB

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