Back to index

glibc  2.9
fcntl.h
Go to the documentation of this file.
00001 /* O_*, F_*, FD_* bit values for SunOS 4.
00002    Copyright (C) 1991, 1992, 1997, 2004 Free Software Foundation, Inc.
00003    This file is part of the GNU C Library.
00004 
00005    The GNU C Library is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Lesser General Public
00007    License as published by the Free Software Foundation; either
00008    version 2.1 of the License, or (at your option) any later version.
00009 
00010    The GNU C Library is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Lesser General Public License for more details.
00014 
00015    You should have received a copy of the GNU Lesser General Public
00016    License along with the GNU C Library; if not, write to the Free
00017    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00018    02111-1307 USA.  */
00019 
00020 #ifndef       _FCNTL_H
00021 #error "Never use <bits/fcntl.h> directly; include <fcntl.h> instead."
00022 #endif
00023 
00024 
00025 /* File access modes for `open' and `fcntl'.  */
00026 #define       O_RDONLY      0      /* Open read-only.  */
00027 #define       O_WRONLY      1      /* Open write-only.  */
00028 #define       O_RDWR        2      /* Open read/write.  */
00029 
00030 
00031 /* Bits OR'd into the second argument to open.  */
00032 #define       O_CREAT              0x0200 /* Create file if it doesn't exist.  */
00033 #define       O_EXCL        0x0800 /* Fail if file already exists.  */
00034 #define       O_TRUNC              0x0400 /* Truncate file to zero length.  */
00035 #define       O_NOCTTY      0x8000 /* Don't assign a controlling terminal.  */
00036 #if defined __USE_BSD || defined __USE_SVID
00037 #define       O_ASYNC              0x0040 /* Send SIGIO to owner when data is ready.  */
00038 #define       O_FSYNC              0x2000 /* Synchronous writes.  */
00039 #define       O_SYNC        O_FSYNC
00040 #endif
00041 
00042 /* File status flags for `open' and `fcntl'.  */
00043 #define       O_APPEND      0x0008 /* Writes append to the file.  */
00044 #define       O_NONBLOCK    0x4000 /* Non-blocking I/O.  */
00045 
00046 /* Sun defines O_NDELAY one way for BSD behavior and another for System V
00047    behavior.  In the GNU C library, you get the BSD behavior unless you
00048    define _USG_SOURCE without also defining _BSD_SOURCE or _GNU_SOURCE.  */
00049 #ifdef __USE_BSD
00050 #define       O_NDELAY      0x0004
00051 #endif
00052 #if !defined (O_NDELAY) && defined (__USE_SVID)
00053 #define       O_NDELAY      0x1000
00054 #endif
00055 
00056 #ifdef __USE_BSD
00057 /* Bits in the file status flags returned by F_GETFL.
00058    These are all the O_* flags, plus FREAD and FWRITE, which are
00059    independent bits set by which of O_RDONLY, O_WRONLY, and O_RDWR, was
00060    given to `open'.  */
00061 #define FREAD        1
00062 #define       FWRITE        2
00063 
00064 /* Traditional Unix names the O_* bits.  */
00065 #define FASYNC              O_ASYNC
00066 #define FCREAT              O_CREAT
00067 #define FEXCL        O_EXCL
00068 #define FTRUNC              O_TRUNC
00069 #define FNOCTTY             O_NOCTTY
00070 #define FFSYNC              O_FSYNC
00071 #define FSYNC        O_SYNC
00072 #define FAPPEND             O_APPEND
00073 #define FNONBLOCK    O_NONBLOCK
00074 #define FNONBIO             O_NONBLOCK
00075 #define FNDELAY             0x0004 /* BSD O_NDELAY.  */
00076 #define       FNBIO         0x1000 /* System V O_NDELAY.  */
00077 #endif
00078 
00079 /* Mask for file access modes.  This is system-dependent in case
00080    some system ever wants to define some other flavor of access.  */
00081 #define       O_ACCMODE     (O_RDONLY|O_WRONLY|O_RDWR)
00082 
00083 /* Values for the second argument to `fcntl'.  */
00084 #define       F_DUPFD              0      /* Duplicate file descriptor.  */
00085 #define       F_GETFD              1      /* Get file descriptor flags.  */
00086 #define       F_SETFD              2      /* Set file descriptor flags.  */
00087 #define       F_GETFL              3      /* Get file status flags.  */
00088 #define       F_SETFL              4      /* Set file status flags.  */
00089 #if defined __USE_BSD || defined __USE_UNIX98
00090 #define       F_GETOWN      5      /* Get owner (receiver of SIGIO).  */
00091 #define       F_SETOWN      6      /* Set owner (receiver of SIGIO).  */
00092 #endif
00093 #define       F_GETLK              7      /* Get record locking info.  */
00094 #define       F_SETLK              8      /* Set record locking info (non-blocking).  */
00095 #define       F_SETLKW      9      /* Set record locking info (blocking).  */
00096 #ifdef __USE_BSD
00097 #define       F_RGETLK      10     /* Get remote record locking info.  */
00098 #define       F_RSETLK      11     /* Set remote locking info (non-blocking).  */
00099 #define       F_CNVT        12     /* Convert a fhandle to an open fd.  */
00100 #define       F_RSETLKW     13     /* Set remote locking info (blocking).  */
00101 #endif
00102 
00103 /* File descriptor flags used with F_GETFD and F_SETFD.  */
00104 #define       FD_CLOEXEC    1      /* Close on exec.  */
00105 
00106 
00107 #include <bits/types.h>
00108 
00109 /* The structure describing an advisory lock.  This is the type of the third
00110    argument to `fcntl' for the F_GETLK, F_SETLK, and F_SETLKW requests.  */
00111 struct flock
00112   {
00113     short int l_type;       /* Type of lock: F_RDLCK, F_WRLCK, or F_UNLCK.  */
00114     short int l_whence;     /* Where `l_start' is relative to (like `lseek').  */
00115     __off_t l_start; /* Offset where the lock begins.  */
00116     __off_t l_len;   /* Size of the locked area; zero means until EOF.  */
00117     short int l_pid; /* Process holding the lock.  */
00118     short int l_xxx; /* Reserved for future use.  */
00119   };
00120 
00121 #ifdef __USE_BSD
00122 /* The structure describing a remote advisory lock.  This is the type of the
00123    third arg to `fcntl' for the F_RGETLK, F_RSETLK, and F_RSETLKW requests.  */
00124 struct eflock
00125   {
00126     short int l_type;       /* Type of lock: F_RDLCK, F_WRLCK, or F_UNLCK.  */
00127     short int l_whence;     /* Where `l_start' is relative to (like `lseek').  */
00128     __off_t l_start; /* Offset where the lock begins.  */
00129     __off_t l_len;   /* Size of the locked area; zero means until EOF.  */
00130     short int l_pid; /* Process holding the lock.  */
00131     short int l_xxx; /* Reserved for future use.  */
00132     long int l_rpid; /* Remote process ID wanting this lock.  */
00133     long int l_rsys; /* Remote system ID wanting this lock.  */
00134   };
00135 
00136 #endif
00137 
00138 
00139 /* Values for the `l_type' field of a `struct flock'.  */
00140 #define       F_RDLCK       1      /* Read lock.  */
00141 #define       F_WRLCK       2      /* Write lock.  */
00142 #define       F_UNLCK       3      /* Remove lock.  */