fcntl.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. /* O_*, F_*, FD_* bit values for Linux/SPARC.
  2. Copyright (C) 1995, 1996, 1997, 1998, 2000 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 Library General Public License as
  6. published by the Free Software Foundation; either version 2 of the
  7. 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. Library General Public License for more details.
  12. You should have received a copy of the GNU Library General Public
  13. License along with the GNU C Library; see the file COPYING.LIB. If not,
  14. write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  15. Boston, MA 02111-1307, USA. */
  16. #ifndef _FCNTLBITS_H
  17. #define _FCNTLBITS_H 1
  18. #include <sys/types.h>
  19. #include <bits/wordsize.h>
  20. /* open/fcntl - O_SYNC is only implemented on blocks devices and on files
  21. located on an ext2 file system */
  22. #define O_RDONLY 0x0000
  23. #define O_WRONLY 0x0001
  24. #define O_RDWR 0x0002
  25. #define O_ACCMODE 0x0003
  26. #define O_APPEND 0x0008
  27. #define O_ASYNC 0x0040
  28. #define O_CREAT 0x0200 /* not fcntl */
  29. #define O_TRUNC 0x0400 /* not fcntl */
  30. #define O_EXCL 0x0800 /* not fcntl */
  31. #define O_SYNC 0x2000
  32. #define O_NONBLOCK 0x4000
  33. #define O_NDELAY (0x0004 | O_NONBLOCK)
  34. #define O_NOCTTY 0x8000 /* not fcntl */
  35. #ifdef __USE_GNU
  36. # define O_DIRECTORY 0x10000 /* must be a directory */
  37. # define O_NOFOLLOW 0x20000 /* don't follow links */
  38. #endif
  39. #ifdef __USE_LARGEFILE64
  40. # if __WORDSIZE == 64
  41. # define O_LARGEFILE 0
  42. # else
  43. # define O_LARGEFILE 0x40000
  44. # endif
  45. #endif
  46. /* For now Linux has synchronisity options for data and read operations.
  47. We define the symbols here but let them do the same as O_SYNC since
  48. this is a superset. */
  49. #if defined __USE_POSIX199309 || defined __USE_UNIX98
  50. # define O_DSYNC O_SYNC /* Synchronize data. */
  51. # define O_RSYNC O_SYNC /* Synchronize read operations. */
  52. #endif
  53. /* Values for the second argument to `fcntl'. */
  54. #define F_DUPFD 0 /* Duplicate file descriptor. */
  55. #define F_GETFD 1 /* Get file descriptor flags. */
  56. #define F_SETFD 2 /* Set file descriptor flags. */
  57. #define F_GETFL 3 /* Get file status flags. */
  58. #define F_SETFL 4 /* Set file status flags. */
  59. #ifdef __USE_BSD
  60. # define F_GETOWN 5 /* Get owner of socket (receiver of SIGIO). */
  61. # define F_SETOWN 6 /* Set owner of socket (receiver of SIGIO). */
  62. #endif
  63. #define F_GETLK 7 /* Get record locking info. */
  64. #define F_SETLK 8 /* Set record locking info (non-blocking). */
  65. #define F_SETLKW 9 /* Set record locking info (blocking). */
  66. #ifdef __USE_GNU
  67. # define F_SETSIG 10 /* Set number of signal to be sent. */
  68. # define F_GETSIG 11 /* Get number of signal to be sent. */
  69. #endif
  70. /* XXX missing */
  71. #define F_GETLK64 7 /* Get record locking info. */
  72. #define F_SETLK64 8 /* Set record locking info (non-blocking). */
  73. #define F_SETLKW64 9 /* Set record locking info (blocking). */
  74. /* for F_[GET|SET]FL */
  75. #define FD_CLOEXEC 1 /* actually anything with low bit set goes */
  76. /* For posix fcntl() and `l_type' field of a `struct flock' for lockf(). */
  77. #define F_RDLCK 1 /* Read lock. */
  78. #define F_WRLCK 2 /* Write lock. */
  79. #define F_UNLCK 3 /* Remove lock. */
  80. /* for old implementation of bsd flock () */
  81. #define F_EXLCK 4 /* or 3 */
  82. #define F_SHLCK 8 /* or 4 */
  83. #ifdef __USE_BSD
  84. /* Operations for bsd flock(), also used by the kernel implementation */
  85. # define LOCK_SH 1 /* shared lock */
  86. # define LOCK_EX 2 /* exclusive lock */
  87. # define LOCK_NB 4 /* or'd with one of the above to prevent
  88. blocking */
  89. # define LOCK_UN 8 /* remove lock */
  90. #endif
  91. struct flock
  92. {
  93. short int l_type; /* Type of lock: F_RDLCK, F_WRLCK, or F_UNLCK. */
  94. short int l_whence; /* Where `l_start' is relative to (like `lseek'). */
  95. #ifndef __USE_FILE_OFFSET64
  96. __off_t l_start; /* Offset where the lock begins. */
  97. __off_t l_len; /* Size of the locked area; zero means until EOF. */
  98. #else
  99. __off64_t l_start; /* Offset where the lock begins. */
  100. __off64_t l_len; /* Size of the locked area; zero means until EOF. */
  101. #endif
  102. __pid_t l_pid; /* Process holding the lock. */
  103. short int __unused;
  104. };
  105. #ifdef __USE_LARGEFILE64
  106. struct flock64
  107. {
  108. short int l_type; /* Type of lock: F_RDLCK, F_WRLCK, or F_UNLCK. */
  109. short int l_whence; /* Where `l_start' is relative to (like `lseek'). */
  110. __off64_t l_start; /* Offset where the lock begins. */
  111. __off64_t l_len; /* Size of the locked area; zero means until EOF. */
  112. __pid_t l_pid; /* Process holding the lock. */
  113. short int __unused;
  114. };
  115. #endif
  116. /* Define some more compatibility macros to be backward compatible with
  117. BSD systems which did not managed to hide these kernel macros. */
  118. #ifdef __USE_BSD
  119. # define FAPPEND O_APPEND
  120. # define FFSYNC O_FSYNC
  121. # define FASYNC O_ASYNC
  122. # define FNONBLOCK O_NONBLOCK
  123. # define FNDELAY O_NDELAY
  124. #endif /* Use BSD. */
  125. #endif