home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 4: GNU Archives / Linux Cubed Series 4 - GNU Archives.iso / gnu / glibc-1.09 / glibc-1 / glibc-1.09.1 / sysdeps / mach / hurd / fcntlbits.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-10-25  |  6.4 KB  |  179 lines

  1. /* O_*, F_*, FD_* bit values for GNU.
  2. Copyright (C) 1993, 1994 Free Software Foundation, Inc.
  3. This file is part of the GNU C Library.
  4.  
  5. The GNU C Library is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU Library General Public License as
  7. published by the Free Software Foundation; either version 2 of the
  8. License, or (at your option) any later version.
  9.  
  10. The GNU C Library is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  13. Library General Public License for more details.
  14.  
  15. You should have received a copy of the GNU Library General Public
  16. License along with the GNU C Library; see the file COPYING.LIB.  If
  17. not, write to the Free Software Foundation, Inc., 675 Mass Ave,
  18. Cambridge, MA 02139, USA.  */
  19.  
  20. #ifndef    _FCNTLBITS_H
  21.  
  22. #define    _FCNTLBITS_H    1
  23.  
  24.  
  25. /* File access modes.  These are understood by io servers; they can be
  26.    passed in `dir_lookup', and are returned by `io_get_openmodes'.
  27.    Consequently they can be passed to `open', `hurd_file_name_lookup', and
  28.    `file_name_lookup'; and are returned by `fcntl' with the F_GETFL
  29.    command.  */
  30.  
  31. /* In GNU, read and write are bits (unlike BSD).  */
  32. #ifdef __USE_GNU
  33. #define    O_READ        O_RDONLY /* Open for reading.  */
  34. #define O_WRITE        O_WRONLY /* Open for writing.  */
  35. #define    O_EXEC        0x0004    /* Open for execution.  */
  36. #endif
  37. /* POSIX.1 standard names.  */
  38. #define    O_RDONLY    0x0001    /* Open read-only.  */
  39. #define    O_WRONLY    0x0002    /* Open write-only.  */
  40. #define    O_RDWR        (O_RDONLY|O_WRONLY) /* Open for reading and writing. */
  41. #define    O_ACCMODE    O_RDWR    /* Mask for file access modes.  */
  42.  
  43.  
  44.  
  45. /* File name translation flags.  These are understood by io servers;
  46.    they can be passed in `dir_lookup', and consequently to `open',
  47.    `hurd_file_name_lookup', and `file_name_lookup'.  */
  48.  
  49. #define    O_CREAT        0x0010    /* Create file if it doesn't exist.  */
  50. #define    O_EXCL        0x0020    /* Fail if file already exists.  */
  51. #ifdef __USE_GNU
  52. #define    O_NOLINK    0x0040    /* No name mappings on final component.  */
  53. #define    O_NOTRANS    0x0080    /* No translator on final component. */
  54. #endif
  55.  
  56.  
  57. /* I/O operating modes.  These are understood by io servers; they can be
  58.    passed in `dir_lookup' and set or fetched with `io_*_openmodes'.
  59.    Consequently they can be passed to `open', `hurd_file_name_lookup',
  60.    `file_name_lookup', and `fcntl' with the F_SETFL command; and are
  61.    returned by `fcntl' with the F_GETFL command.  */
  62.  
  63. #define    O_APPEND    0x0100    /* Writes always append to the file.  */
  64. #ifdef __USE_BSD
  65. #define    O_ASYNC        0x0200    /* Send SIGIO to owner when data is ready.  */
  66. #define    O_FSYNC        0x0400    /* Synchronous writes.  */
  67. #define    O_SYNC        O_FSYNC
  68. #endif
  69. #ifdef __USE_GNU
  70. #define    O_NOATIME    0x0800    /* Don't set access time on read (owner).  */
  71. #endif
  72.  
  73.  
  74. /* The name O_NONBLOCK is unfortunately overloaded; it is both a file name
  75.    translation flag and an I/O operating mode.  O_NDELAY is the deprecated
  76.    BSD name for the same flag, overloaded in the same way.
  77.  
  78.    When used in `dir_lookup' (and consequently `open', `hurd_file_name_lookup',
  79.    or `file_name_lookup'), O_NONBLOCK says the open should return immediately
  80.    instead of blocking for any significant length of time (e.g., to wait
  81.    for carrier detect on a serial line).  It is also saved as an I/O
  82.    operating mode, and after open has the following meaning.
  83.  
  84.    When used in `io_*_openmodes' (and consequently `fcntl' with the F_SETFL
  85.    command), the O_NONBLOCK flag means to do nonblocking i/o: any i/o
  86.    operation that would block for any significant length of time will instead
  87.    fail with EAGAIN.  */
  88.  
  89. #define    O_NONBLOCK    0x0008    /* Non-blocking open or non-blocking I/O.  */
  90. #ifdef __USE_BSD
  91. #define    O_NDELAY    O_NONBLOCK /* Deprecated.  */
  92. #endif
  93.  
  94.  
  95. #ifdef __USE_GNU
  96. /* Mask of bits which are understood by io servers.  */
  97. #define O_HURD        0xffff    /* XXX name? want this? */
  98. #endif
  99.  
  100.  
  101. /* Open-time action flags.  These are understood by `hurd_file_name_lookup'
  102.    and consequently by `open' and `file_name_lookup'.  They are not preserved
  103.    once the file has been opened.  */
  104.  
  105. #define    O_TRUNC        0x00010000 /* Truncate file to zero length.  */
  106. #ifdef    __USE_MISC
  107. #define    O_SHLOCK    0x00020000 /* Open with shared file lock.  */
  108. #define    O_EXLOCK    0x00040000 /* Open with exclusive file lock.  */
  109. #endif
  110.  
  111.  
  112. /* Controlling terminal flags.  These are understood only by `open',
  113.    and are not preserved once the file has been opened.  */
  114.  
  115. #ifdef __USE_GNU
  116. #define    O_IGNORE_CTTY    0x00080000 /* Don't do any ctty magic at all.  */
  117. #endif
  118. /* `open' never assigns a controlling terminal in GNU.  */
  119. #define    O_NOCTTY    0    /* Don't assign a controlling terminal.  */
  120.  
  121.  
  122. #ifdef __USE_BSD
  123. /* Bits in the file status flags returned by F_GETFL.  */
  124. #define FREAD        O_RDONLY
  125. #define    FWRITE        O_WRONLY
  126.  
  127. /* Traditional BSD names the O_* bits.  */
  128. #define FASYNC        O_ASYNC
  129. #define FCREAT        O_CREAT
  130. #define FEXCL        O_EXCL
  131. #define FTRUNC        O_TRUNC
  132. #define FNOCTTY        O_NOCTTY
  133. #define FFSYNC        O_FSYNC
  134. #define FSYNC        O_SYNC
  135. #define FAPPEND        O_APPEND
  136. #define FNONBLOCK    O_NONBLOCK
  137. #define FNDELAY        O_NDELAY
  138. #endif
  139.  
  140.  
  141. /* Values for the second argument to `fcntl'.  */
  142. #define    F_DUPFD          0    /* Duplicate file descriptor.  */
  143. #define    F_GETFD        1    /* Get file descriptor flags.  */
  144. #define    F_SETFD        2    /* Set file descriptor flags.  */
  145. #define    F_GETFL        3    /* Get file status flags.  */
  146. #define    F_SETFL        4    /* Set file status flags.  */
  147. #ifdef __USE_BSD
  148. #define    F_GETOWN    5    /* Get owner (receiver of SIGIO).  */
  149. #define    F_SETOWN    6    /* Set owner (receiver of SIGIO).  */
  150. #endif
  151. #define    F_GETLK        7    /* Get record locking info.  */
  152. #define    F_SETLK        8    /* Set record locking info (non-blocking).  */
  153. #define    F_SETLKW    9    /* Set record locking info (blocking).  */
  154.  
  155. /* File descriptor flags used with F_GETFD and F_SETFD.  */
  156. #define    FD_CLOEXEC    1    /* Close on exec.  */
  157.  
  158.  
  159. #include <gnu/types.h>
  160.  
  161. /* The structure describing an advisory lock.  This is the type of the third
  162.    argument to `fcntl' for the F_GETLK, F_SETLK, and F_SETLKW requests.  */
  163. struct flock
  164.   {
  165.     int l_type;        /* Type of lock: F_RDLCK, F_WRLCK, or F_UNLCK.  */
  166.     int l_whence;    /* Where `l_start' is relative to (like `lseek').  */
  167.     __off_t l_start;    /* Offset where the lock begins.  */
  168.     __off_t l_len;    /* Size of the locked area; zero means until EOF.  */
  169.     __pid_t l_pid;    /* Process holding the lock.  */
  170.   };
  171.  
  172. /* Values for the `l_type' field of a `struct flock'.  */
  173. #define    F_RDLCK    1    /* Read lock.  */
  174. #define    F_WRLCK    2    /* Write lock.  */
  175. #define    F_UNLCK    3    /* Remove lock.  */
  176.  
  177.  
  178. #endif    /* fcntlbits.h */
  179.