home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 15 / 15.iso / s / s053 / 8.ddi / usr / include / sys / fcntl.h < prev    next >
Encoding:
C/C++ Source or Header  |  1990-12-08  |  5.0 KB  |  181 lines

  1. /*    Copyright (c) 1990 UNIX System Laboratories, Inc.    */
  2. /*    Copyright (c) 1984, 1986, 1987, 1988, 1989, 1990 AT&T    */
  3. /*      All Rights Reserved      */
  4.  
  5. /*    THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF         */
  6. /*    UNIX System Laboratories, Inc.                         */
  7. /*    The copyright notice above does not evidence any       */
  8. /*    actual or intended publication of such source code.    */
  9.  
  10. #ifndef _SYS_FCNTL_H
  11. #define _SYS_FCNTL_H
  12.  
  13. #ident    "@(#)/usr/include/sys/fcntl.h.sl 1.1 4.0 12/08/90 4674 AT&T-USL"
  14. #ifndef _SYS_TYPES_H
  15. #include <sys/types.h>
  16. #endif
  17.  
  18. /*
  19.  * Flag values accessible to open(2) and fcntl(2)
  20.  * (the first three can only be set by open).
  21.  */
  22. #define    O_RDONLY    0
  23. #define    O_WRONLY    1
  24. #define    O_RDWR        2
  25. #if !defined(_POSIX_SOURCE)
  26. #define    O_NDELAY    0x04    /* non-blocking I/O */
  27. #endif /* !defined(_POSIX_SOURCE) */
  28. #define    O_APPEND    0x08    /* append (writes guaranteed at the end) */
  29. #if !defined(_POSIX_SOURCE) || defined(_XOPEN_SOURCE)
  30. #define    O_SYNC        0x10    /* synchronous write option */
  31. #endif /* !defined(_POSIX_SOURCE) || defined(_XOPEN_SOURCE */
  32.  
  33. /*
  34.  * The following flag is added for asynchronous raw disk io feature 
  35.  */
  36. #define O_RAIOSIG    0x20    /* cause a signal for a completed RAIO request */ 
  37.  
  38. #define    O_NONBLOCK    0x80    /* non-blocking I/O (POSIX) */
  39.  
  40. /*
  41.  * Flag values accessible only to open(2).
  42.  */
  43. #define    O_CREAT        0x100    /* open with file create (uses third open arg) */
  44. #define    O_TRUNC        0x200    /* open with truncation */
  45. #define    O_EXCL        0x400    /* exclusive open */
  46. #define    O_NOCTTY    0x800    /* don't allocate controlling tty (POSIX) */
  47.  
  48. /* fcntl(2) requests */
  49. #define    F_DUPFD        0    /* Duplicate fildes */
  50. #define    F_GETFD        1    /* Get fildes flags */
  51. #define    F_SETFD        2    /* Set fildes flags */
  52. #define    F_GETFL        3    /* Get file flags */
  53. #define    F_SETFL        4    /* Set file flags */
  54.  
  55. /*
  56.  * Applications that read /dev/mem must be built like the kernel.  A
  57.  * new symbol "_KMEMUSER" is defined for this purpose.
  58.  */
  59. #if defined(_KERNEL) || defined(_KMEMUSER)
  60. #define    F_GETLK        14    /* Get file lock */
  61. #define    F_O_GETLK    5    /* SVR3 Get file lock */
  62.  
  63. #else    /* user definition */
  64.  
  65. #if defined(_STYPES)    /* SVR3 definition */
  66. #define    F_GETLK        5    /* Get file lock */
  67. #else
  68. #define    F_GETLK        14    /* Get file lock */
  69. #endif    /* defined(_STYPES) */
  70.  
  71. #endif    /* defined(_KERNEL) */
  72.  
  73. #define    F_SETLK        6    /* Set file lock */
  74. #define    F_SETLKW    7    /* Set file lock and wait */
  75.  
  76. #if !defined(_POSIX_SOURCE)
  77. #define    F_CHKFL        8    /* Unused */
  78.  
  79. #define    F_ALLOCSP    10    /* Reserved */
  80. #define    F_FREESP    11    /* Free file space */
  81.  
  82. #define F_RSETLK    20    /* Remote SETLK for NFS */
  83. #define F_RGETLK    21    /* Remote GETLK for NFS */
  84. #define F_RSETLKW    22    /* Remote SETLKW for NFS */
  85.  
  86. #define    F_GETOWN    23    /* Get owner (socket emulation) */
  87. #define    F_SETOWN    24    /* Set owner (socket emulation) */
  88. #endif /* !defined(_POSIX_SOURCE) */
  89.  
  90.  
  91. #define F_CHSIZE    0x6000  /* XENIX chsize() system call */
  92. #define F_RDCHK     0x6001  /* XENIX rdchk() system call */
  93.  
  94. /*
  95.  * Fcntl(2) requests made from the XENIX locking(S) system call.  These fcntl()
  96.  * requests are made only from the kernel.
  97.  *
  98.  * N.B.  The high nibble of the high byte is F_SETLK or F_SETLKW, and the low
  99.  *       nibble of the high byte is F_UNLCK, F_WRLCK, or F_RDLCK.  However, *   no code actually relies on this.
  100.  */
  101.  
  102. #define F_LK_UNLCK  0x6300  /* locking() LK_UNLCK request */
  103. #define F_LK_LOCK   0x7200  /* locking() LK_LOCK request */
  104. #define F_LK_NBLCK  0x6200  /* locking() LK_NBLCK request */
  105. #define F_LK_RLCK   0x7100  /* locking() LK_RLCK request */
  106. #define F_LK_NBRLCK 0x6100  /* locking() LK_NBRLCK request */
  107.  
  108. #define LK_CMDTYPE(x)   ((x >> 12) & 0x7) /* get high nibble of high byte */
  109. #define LK_LCKTYPE(x)   ((x >> 8) & 0x7)  /* get low nibble of high byte */
  110.  
  111.  
  112. /*
  113.  * File segment locking set data type - information passed to system by user.
  114.  */
  115. #if defined(_KERNEL) || defined(_KMEMUSER)
  116.     /* EFT definition */
  117. typedef struct flock {
  118.     short    l_type;
  119.     short    l_whence;
  120.     off_t    l_start;
  121.     off_t    l_len;        /* len == 0 means until end of file */
  122.         long    l_sysid;
  123.         pid_t    l_pid;
  124.     long    pad[4];        /* reserve area */
  125. } flock_t;
  126.  
  127. typedef struct o_flock {
  128.     short    l_type;
  129.     short    l_whence;
  130.     long    l_start;
  131.     long    l_len;        /* len == 0 means until end of file */
  132.         short   l_sysid;
  133.         o_pid_t l_pid;
  134. } o_flock_t;
  135.  
  136. #else        /* user level definition */
  137.  
  138. #if defined(_STYPES)
  139.     /* SVR3 definition */
  140. typedef struct flock {
  141.     short    l_type;
  142.     short    l_whence;
  143.     off_t    l_start;
  144.     off_t    l_len;        /* len == 0 means until end of file */
  145.     short    l_sysid;
  146.         o_pid_t    l_pid;
  147. } flock_t;
  148.  
  149.  
  150. #else
  151.  
  152. typedef struct flock {
  153.     short    l_type;
  154.     short    l_whence;
  155.     off_t    l_start;
  156.     off_t    l_len;        /* len == 0 means until end of file */
  157.     long    l_sysid;
  158.         pid_t    l_pid;
  159.     long    pad[4];        /* reserve area */
  160. } flock_t;
  161.  
  162. #endif    /* defined(_STYPES) */
  163.  
  164. #endif    /* defined(_KERNEL) */
  165.  
  166. /*
  167.  * File segment locking types.
  168.  */
  169. #define    F_RDLCK    01    /* Read lock */
  170. #define    F_WRLCK    02    /* Write lock */
  171. #define    F_UNLCK    03    /* Remove lock(s) */
  172.  
  173. /*
  174.  * POSIX constants 
  175.  */
  176.  
  177. #define    O_ACCMODE    3    /* Mask for file access modes */
  178. #define    FD_CLOEXEC    1    /* close on exec flag */
  179.  
  180. #endif    /* _SYS_FCNTL_H */
  181.