Back to index

glibc  2.9
fcntl.h
Go to the documentation of this file.
00001 /* O_*, F_*, FD_* bit values for SGI Irix 4.
00002    Copyright (C) 1994, 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              00400  /* Create file if it doesn't exist.  */
00033 #define       O_EXCL        02000  /* Fail if file already exists.  */
00034 #define       O_TRUNC              01000  /* Truncate file to zero length.  */
00035 #ifdef __USE_MISC
00036 #define       O_SYNC        00020  /* Synchronous writes.  */
00037 #define       O_FSYNC              O_SYNC
00038 #define       O_ASYNC              00100  /* Send SIGIO to owner when data is ready.  */
00039 #endif
00040 
00041 /* File status flags for `open' and `fcntl'.  */
00042 #define       O_APPEND      000010 /* Writes append to the file.  */
00043 #ifdef __USE_BSD
00044 #define       O_NDELAY      000004 /* Non-blocking I/O.  */
00045 #endif
00046 #define O_NONBLOCK   000200 /* POSIX.1 non-blocking I/O.  */
00047 
00048 /* Mask for file access modes.  This is system-dependent in case
00049    some system ever wants to define some other flavor of access.  */
00050 #define       O_ACCMODE     (O_RDONLY|O_WRONLY|O_RDWR)
00051 
00052 /* Values for the second argument to `fcntl'.  */
00053 #define       F_DUPFD              0      /* Duplicate file descriptor.  */
00054 #define       F_GETFD              1      /* Get file descriptor flags.  */
00055 #define       F_SETFD              2      /* Set file descriptor flags.  */
00056 #define       F_GETFL              3      /* Get file status flags.  */
00057 #define       F_SETFL              4      /* Set file status flags.  */
00058 #define       F_GETLK              5      /* Get record locking info.  */
00059 #define       F_SETLK              6      /* Set record locking info.  */
00060 #define       F_SETLKW      7      /* Set record locking info, wait.  */
00061 #ifdef __USE_MISC
00062 #define F_CHKFL         8       /* Check legality of file flag changes.  */
00063 #define F_ALLOCSP       10
00064 #define F_FREESP        11
00065 #define F_SETBSDLK      12      /* Set Berkeley record lock.  */
00066 #define F_SETBSDLKW     13      /* Set Berkeley record lock and wait.  */
00067 #define F_RGETLK        20      /* Get info on a remote lock.  */
00068 #define F_RSETLK        21      /* Set or unlock a remote lock.  */
00069 #define F_RSETLKW       22      /* Set or unlock a remote lock and wait.  */
00070 #endif
00071 #if defined __USE_BSD || defined __USE_UNIX98
00072 #define F_GETOWN        10      /* Get owner; only works on sockets.  */
00073 #define F_SETOWN        11      /* Set owner; only works on sockets.  */
00074 #endif
00075 
00076 
00077 /* File descriptor flags used with F_GETFD and F_SETFD.  */
00078 #define       FD_CLOEXEC    1      /* Close on exec.  */
00079 
00080 
00081 #include <bits/types.h>
00082 
00083 /* The structure describing an advisory lock.  This is the type of the third
00084    argument to `fcntl' for the F_GETLK, F_SETLK, and F_SETLKW requests.  */
00085 struct flock
00086   {
00087     short int l_type;       /* Type of lock: F_RDLCK, F_WRLCK, or F_UNLCK.  */
00088     short int l_whence;     /* Where `l_start' is relative to (like `lseek').  */
00089     __off_t l_start; /* Offset where the lock begins.  */
00090     __off_t l_len;   /* Size of the locked area; zero means until EOF.  */
00091     short int l_sysid;      /* System ID where locking process resides. */
00092     short int l_pid; /* Process holding the lock.  */
00093   };
00094 
00095 /* Values for the `l_type' field of a `struct flock'.  */
00096 #define       F_RDLCK       1      /* Read lock.  */
00097 #define       F_WRLCK       2      /* Write lock.  */
00098 #define       F_UNLCK       3      /* Remove lock.  */
00099 
00100 
00101 /* Define some more compatibility macros to be backward compatible with
00102    BSD systems which did not managed to hide these kernel macros.  */
00103 #ifdef __USE_BSD
00104 #define       FAPPEND              O_APPEND
00105 #define       FFSYNC        O_FSYNC
00106 #define       FASYNC        O_ASYNC
00107 #define       FNONBLOCK     O_NONBLOCK
00108 #define       FNDELAY              O_NDELAY
00109 #endif /* Use BSD.  */