PageRenderTime 3949ms CodeModel.GetById 24ms RepoModel.GetById 1ms app.codeStats 0ms

/aarch64-linux-gnu/libc/usr/include/bits/fcntl-linux.h

https://gitlab.com/infected_/linaro_aarch64-linux-gnu-5.3.x
C Header | 419 lines | 264 code | 52 blank | 103 comment | 3 complexity | 4287db62ad99a1ad6824b1d30a937766 MD5 | raw file
  1. /* O_*, F_*, FD_* bit values for Linux.
  2. Copyright (C) 2001-2015 Free Software Foundation, Inc.
  3. This file is part of the GNU C Library.
  4. The GNU C Library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Lesser General Public
  6. License as published by the Free Software Foundation; either
  7. version 2.1 of the License, or (at your option) any later version.
  8. The GNU C Library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public
  13. License along with the GNU C Library; if not, see
  14. <http://www.gnu.org/licenses/>. */
  15. #ifndef _FCNTL_H
  16. # error "Never use <bits/fcntl-linux.h> directly; include <fcntl.h> instead."
  17. #endif
  18. /* This file contains shared definitions between Linux architectures
  19. and is included by <bits/fcntl.h> to declare them. The various
  20. #ifndef cases allow the architecture specific file to define those
  21. values with different values.
  22. A minimal <bits/fcntl.h> contains just:
  23. struct flock {...}
  24. #ifdef __USE_LARGEFILE64
  25. struct flock64 {...}
  26. #endif
  27. #include <bits/fcntl-linux.h>
  28. */
  29. #ifdef __USE_GNU
  30. # include <bits/uio.h>
  31. #endif
  32. /* open/fcntl. */
  33. #define O_ACCMODE 0003
  34. #define O_RDONLY 00
  35. #define O_WRONLY 01
  36. #define O_RDWR 02
  37. #ifndef O_CREAT
  38. # define O_CREAT 0100 /* Not fcntl. */
  39. #endif
  40. #ifndef O_EXCL
  41. # define O_EXCL 0200 /* Not fcntl. */
  42. #endif
  43. #ifndef O_NOCTTY
  44. # define O_NOCTTY 0400 /* Not fcntl. */
  45. #endif
  46. #ifndef O_TRUNC
  47. # define O_TRUNC 01000 /* Not fcntl. */
  48. #endif
  49. #ifndef O_APPEND
  50. # define O_APPEND 02000
  51. #endif
  52. #ifndef O_NONBLOCK
  53. # define O_NONBLOCK 04000
  54. #endif
  55. #ifndef O_NDELAY
  56. # define O_NDELAY O_NONBLOCK
  57. #endif
  58. #ifndef O_SYNC
  59. # define O_SYNC 04010000
  60. #endif
  61. #define O_FSYNC O_SYNC
  62. #ifndef O_ASYNC
  63. # define O_ASYNC 020000
  64. #endif
  65. #ifndef __O_LARGEFILE
  66. # define __O_LARGEFILE 0100000
  67. #endif
  68. #ifndef __O_DIRECTORY
  69. # define __O_DIRECTORY 0200000
  70. #endif
  71. #ifndef __O_NOFOLLOW
  72. # define __O_NOFOLLOW 0400000
  73. #endif
  74. #ifndef __O_CLOEXEC
  75. # define __O_CLOEXEC 02000000
  76. #endif
  77. #ifndef __O_DIRECT
  78. # define __O_DIRECT 040000
  79. #endif
  80. #ifndef __O_NOATIME
  81. # define __O_NOATIME 01000000
  82. #endif
  83. #ifndef __O_PATH
  84. # define __O_PATH 010000000
  85. #endif
  86. #ifndef __O_DSYNC
  87. # define __O_DSYNC 010000
  88. #endif
  89. #ifndef __O_TMPFILE
  90. # define __O_TMPFILE 020200000
  91. #endif
  92. #ifndef F_GETLK
  93. # ifndef __USE_FILE_OFFSET64
  94. # define F_GETLK 5 /* Get record locking info. */
  95. # define F_SETLK 6 /* Set record locking info (non-blocking). */
  96. # define F_SETLKW 7 /* Set record locking info (blocking). */
  97. # else
  98. # define F_GETLK F_GETLK64 /* Get record locking info. */
  99. # define F_SETLK F_SETLK64 /* Set record locking info (non-blocking).*/
  100. # define F_SETLKW F_SETLKW64 /* Set record locking info (blocking). */
  101. # endif
  102. #endif
  103. #ifndef F_GETLK64
  104. # define F_GETLK64 12 /* Get record locking info. */
  105. # define F_SETLK64 13 /* Set record locking info (non-blocking). */
  106. # define F_SETLKW64 14 /* Set record locking info (blocking). */
  107. #endif
  108. /* open file description locks.
  109. Usually record locks held by a process are released on *any* close and are
  110. not inherited across a fork.
  111. These cmd values will set locks that conflict with process-associated record
  112. locks, but are "owned" by the opened file description, not the process.
  113. This means that they are inherited across fork or clone with CLONE_FILES
  114. like BSD (flock) locks, and they are only released automatically when the
  115. last reference to the the file description against which they were acquired
  116. is put. */
  117. #ifdef __USE_GNU
  118. # define F_OFD_GETLK 36
  119. # define F_OFD_SETLK 37
  120. # define F_OFD_SETLKW 38
  121. #endif
  122. #ifdef __USE_LARGEFILE64
  123. # define O_LARGEFILE __O_LARGEFILE
  124. #endif
  125. #ifdef __USE_XOPEN2K8
  126. # define O_DIRECTORY __O_DIRECTORY /* Must be a directory. */
  127. # define O_NOFOLLOW __O_NOFOLLOW /* Do not follow links. */
  128. # define O_CLOEXEC __O_CLOEXEC /* Set close_on_exec. */
  129. #endif
  130. #ifdef __USE_GNU
  131. # define O_DIRECT __O_DIRECT /* Direct disk access. */
  132. # define O_NOATIME __O_NOATIME /* Do not set atime. */
  133. # define O_PATH __O_PATH /* Resolve pathname but do not open file. */
  134. # define O_TMPFILE __O_TMPFILE /* Atomically create nameless file. */
  135. #endif
  136. /* For now, Linux has no separate synchronicitiy options for read
  137. operations. We define O_RSYNC therefore as the same as O_SYNC
  138. since this is a superset. */
  139. #if defined __USE_POSIX199309 || defined __USE_UNIX98
  140. # define O_DSYNC __O_DSYNC /* Synchronize data. */
  141. # if defined __O_RSYNC
  142. # define O_RSYNC __O_RSYNC /* Synchronize read operations. */
  143. # else
  144. # define O_RSYNC O_SYNC /* Synchronize read operations. */
  145. # endif
  146. #endif
  147. /* Values for the second argument to `fcntl'. */
  148. #define F_DUPFD 0 /* Duplicate file descriptor. */
  149. #define F_GETFD 1 /* Get file descriptor flags. */
  150. #define F_SETFD 2 /* Set file descriptor flags. */
  151. #define F_GETFL 3 /* Get file status flags. */
  152. #define F_SETFL 4 /* Set file status flags. */
  153. #ifndef __F_SETOWN
  154. # define __F_SETOWN 8
  155. # define __F_GETOWN 9
  156. #endif
  157. #if defined __USE_UNIX98 || defined __USE_XOPEN2K8
  158. # define F_SETOWN __F_SETOWN /* Get owner (process receiving SIGIO). */
  159. # define F_GETOWN __F_GETOWN /* Set owner (process receiving SIGIO). */
  160. #endif
  161. #ifndef __F_SETSIG
  162. # define __F_SETSIG 10 /* Set number of signal to be sent. */
  163. # define __F_GETSIG 11 /* Get number of signal to be sent. */
  164. #endif
  165. #ifndef __F_SETOWN_EX
  166. # define __F_SETOWN_EX 15 /* Get owner (thread receiving SIGIO). */
  167. # define __F_GETOWN_EX 16 /* Set owner (thread receiving SIGIO). */
  168. #endif
  169. #ifdef __USE_GNU
  170. # define F_SETSIG __F_SETSIG /* Set number of signal to be sent. */
  171. # define F_GETSIG __F_GETSIG /* Get number of signal to be sent. */
  172. # define F_SETOWN_EX __F_SETOWN_EX /* Get owner (thread receiving SIGIO). */
  173. # define F_GETOWN_EX __F_GETOWN_EX /* Set owner (thread receiving SIGIO). */
  174. #endif
  175. #ifdef __USE_GNU
  176. # define F_SETLEASE 1024 /* Set a lease. */
  177. # define F_GETLEASE 1025 /* Enquire what lease is active. */
  178. # define F_NOTIFY 1026 /* Request notifications on a directory. */
  179. # define F_SETPIPE_SZ 1031 /* Set pipe page size array. */
  180. # define F_GETPIPE_SZ 1032 /* Set pipe page size array. */
  181. #endif
  182. #ifdef __USE_XOPEN2K8
  183. # define F_DUPFD_CLOEXEC 1030 /* Duplicate file descriptor with
  184. close-on-exit set. */
  185. #endif
  186. /* For F_[GET|SET]FD. */
  187. #define FD_CLOEXEC 1 /* Actually anything with low bit set goes */
  188. #ifndef F_RDLCK
  189. /* For posix fcntl() and `l_type' field of a `struct flock' for lockf(). */
  190. # define F_RDLCK 0 /* Read lock. */
  191. # define F_WRLCK 1 /* Write lock. */
  192. # define F_UNLCK 2 /* Remove lock. */
  193. #endif
  194. /* For old implementation of BSD flock. */
  195. #ifndef F_EXLCK
  196. # define F_EXLCK 4 /* or 3 */
  197. # define F_SHLCK 8 /* or 4 */
  198. #endif
  199. #ifdef __USE_MISC
  200. /* Operations for BSD flock, also used by the kernel implementation. */
  201. # define LOCK_SH 1 /* Shared lock. */
  202. # define LOCK_EX 2 /* Exclusive lock. */
  203. # define LOCK_NB 4 /* Or'd with one of the above to prevent
  204. blocking. */
  205. # define LOCK_UN 8 /* Remove lock. */
  206. #endif
  207. #ifdef __USE_GNU
  208. # define LOCK_MAND 32 /* This is a mandatory flock: */
  209. # define LOCK_READ 64 /* ... which allows concurrent read operations. */
  210. # define LOCK_WRITE 128 /* ... which allows concurrent write operations. */
  211. # define LOCK_RW 192 /* ... Which allows concurrent read & write operations. */
  212. #endif
  213. #ifdef __USE_GNU
  214. /* Types of directory notifications that may be requested with F_NOTIFY. */
  215. # define DN_ACCESS 0x00000001 /* File accessed. */
  216. # define DN_MODIFY 0x00000002 /* File modified. */
  217. # define DN_CREATE 0x00000004 /* File created. */
  218. # define DN_DELETE 0x00000008 /* File removed. */
  219. # define DN_RENAME 0x00000010 /* File renamed. */
  220. # define DN_ATTRIB 0x00000020 /* File changed attributes. */
  221. # define DN_MULTISHOT 0x80000000 /* Don't remove notifier. */
  222. #endif
  223. #ifdef __USE_GNU
  224. /* Owner types. */
  225. enum __pid_type
  226. {
  227. F_OWNER_TID = 0, /* Kernel thread. */
  228. F_OWNER_PID, /* Process. */
  229. F_OWNER_PGRP, /* Process group. */
  230. F_OWNER_GID = F_OWNER_PGRP /* Alternative, obsolete name. */
  231. };
  232. /* Structure to use with F_GETOWN_EX and F_SETOWN_EX. */
  233. struct f_owner_ex
  234. {
  235. enum __pid_type type; /* Owner type of ID. */
  236. __pid_t pid; /* ID of owner. */
  237. };
  238. #endif
  239. /* Define some more compatibility macros to be backward compatible with
  240. BSD systems which did not managed to hide these kernel macros. */
  241. #ifdef __USE_MISC
  242. # define FAPPEND O_APPEND
  243. # define FFSYNC O_FSYNC
  244. # define FASYNC O_ASYNC
  245. # define FNONBLOCK O_NONBLOCK
  246. # define FNDELAY O_NDELAY
  247. #endif /* Use misc. */
  248. #ifndef __POSIX_FADV_DONTNEED
  249. # define __POSIX_FADV_DONTNEED 4
  250. # define __POSIX_FADV_NOREUSE 5
  251. #endif
  252. /* Advise to `posix_fadvise'. */
  253. #ifdef __USE_XOPEN2K
  254. # define POSIX_FADV_NORMAL 0 /* No further special treatment. */
  255. # define POSIX_FADV_RANDOM 1 /* Expect random page references. */
  256. # define POSIX_FADV_SEQUENTIAL 2 /* Expect sequential page references. */
  257. # define POSIX_FADV_WILLNEED 3 /* Will need these pages. */
  258. # define POSIX_FADV_DONTNEED __POSIX_FADV_DONTNEED /* Don't need these pages. */
  259. # define POSIX_FADV_NOREUSE __POSIX_FADV_NOREUSE /* Data will be accessed once. */
  260. #endif
  261. #ifdef __USE_GNU
  262. /* Flags for SYNC_FILE_RANGE. */
  263. # define SYNC_FILE_RANGE_WAIT_BEFORE 1 /* Wait upon writeout of all pages
  264. in the range before performing the
  265. write. */
  266. # define SYNC_FILE_RANGE_WRITE 2 /* Initiate writeout of all those
  267. dirty pages in the range which are
  268. not presently under writeback. */
  269. # define SYNC_FILE_RANGE_WAIT_AFTER 4 /* Wait upon writeout of all pages in
  270. the range after performing the
  271. write. */
  272. /* Flags for SPLICE and VMSPLICE. */
  273. # define SPLICE_F_MOVE 1 /* Move pages instead of copying. */
  274. # define SPLICE_F_NONBLOCK 2 /* Don't block on the pipe splicing
  275. (but we may still block on the fd
  276. we splice from/to). */
  277. # define SPLICE_F_MORE 4 /* Expect more data. */
  278. # define SPLICE_F_GIFT 8 /* Pages passed in are a gift. */
  279. /* Flags for fallocate. */
  280. # define FALLOC_FL_KEEP_SIZE 1 /* Don't extend size of file
  281. even if offset + len is
  282. greater than file size. */
  283. # define FALLOC_FL_PUNCH_HOLE 2 /* Create a hole in the file. */
  284. # define FALLOC_FL_COLLAPSE_RANGE 8 /* Remove a range of a file
  285. without leaving a
  286. hole. */
  287. # define FALLOC_FL_ZERO_RANGE 16 /* Convert a range of a
  288. file to zeros. */
  289. /* File handle structure. */
  290. struct file_handle
  291. {
  292. unsigned int handle_bytes;
  293. int handle_type;
  294. /* File identifier. */
  295. unsigned char f_handle[0];
  296. };
  297. /* Maximum handle size (for now). */
  298. # define MAX_HANDLE_SZ 128
  299. #endif
  300. __BEGIN_DECLS
  301. #ifdef __USE_GNU
  302. /* Provide kernel hint to read ahead. */
  303. extern ssize_t readahead (int __fd, __off64_t __offset, size_t __count)
  304. __THROW;
  305. /* Selective file content synch'ing.
  306. This function is a possible cancellation point and therefore not
  307. marked with __THROW. */
  308. extern int sync_file_range (int __fd, __off64_t __offset, __off64_t __count,
  309. unsigned int __flags);
  310. /* Splice address range into a pipe.
  311. This function is a possible cancellation point and therefore not
  312. marked with __THROW. */
  313. extern ssize_t vmsplice (int __fdout, const struct iovec *__iov,
  314. size_t __count, unsigned int __flags);
  315. /* Splice two files together.
  316. This function is a possible cancellation point and therefore not
  317. marked with __THROW. */
  318. extern ssize_t splice (int __fdin, __off64_t *__offin, int __fdout,
  319. __off64_t *__offout, size_t __len,
  320. unsigned int __flags);
  321. /* In-kernel implementation of tee for pipe buffers.
  322. This function is a possible cancellation point and therefore not
  323. marked with __THROW. */
  324. extern ssize_t tee (int __fdin, int __fdout, size_t __len,
  325. unsigned int __flags);
  326. /* Reserve storage for the data of the file associated with FD.
  327. This function is a possible cancellation point and therefore not
  328. marked with __THROW. */
  329. # ifndef __USE_FILE_OFFSET64
  330. extern int fallocate (int __fd, int __mode, __off_t __offset, __off_t __len);
  331. # else
  332. # ifdef __REDIRECT
  333. extern int __REDIRECT (fallocate, (int __fd, int __mode, __off64_t __offset,
  334. __off64_t __len),
  335. fallocate64);
  336. # else
  337. # define fallocate fallocate64
  338. # endif
  339. # endif
  340. # ifdef __USE_LARGEFILE64
  341. extern int fallocate64 (int __fd, int __mode, __off64_t __offset,
  342. __off64_t __len);
  343. # endif
  344. /* Map file name to file handle. */
  345. extern int name_to_handle_at (int __dfd, const char *__name,
  346. struct file_handle *__handle, int *__mnt_id,
  347. int __flags) __THROW;
  348. /* Open file using the file handle.
  349. This function is a possible cancellation point and therefore not
  350. marked with __THROW. */
  351. extern int open_by_handle_at (int __mountdirfd, struct file_handle *__handle,
  352. int __flags);
  353. #endif /* use GNU */
  354. __END_DECLS