2.9
[glibc/nacl-glibc.git] / sysdeps / unix / sysv / bits / fcntl.h
blob0eb81aa6e3c0403b712c5cab8d67411fcba8434f
1 /* O_*, F_*, FD_* bit values for System V.
2 Copyright (C) 1991, 1992, 1997 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
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 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, write to the Free
17 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18 02111-1307 USA. */
20 #ifndef _FCNTL_H
21 #error "Never use <bits/fcntl.h> directly; include <fcntl.h> instead."
22 #endif
25 /* File access modes for `open' and `fcntl'. */
26 #define O_RDONLY 0 /* Open read-only. */
27 #define O_WRONLY 1 /* Open write-only. */
28 #define O_RDWR 2 /* Open read/write. */
31 /* Bits OR'd into the second argument to open. */
32 #define O_CREAT 00400 /* Create file if it doesn't exist. */
33 #define O_EXCL 02000 /* Fail if file already exists. */
34 #define O_TRUNC 01000 /* Truncate file to zero length. */
35 #if defined __USE_BSD || defined __USE_SVID
36 #define O_SYNC 00020 /* Synchronous writes. */
37 #define O_FSYNC O_SYNC
38 #endif
40 /* File status flags for `open' and `fcntl'. */
41 #define O_APPEND 000010 /* Writes append to the file. */
42 #define O_NONBLOCK 000004 /* Non-blocking I/O. */
44 #ifdef __USE_BSD
45 /* System V doesn't support POSIX.1 O_NONBLOCK, but O_NDELAY is close. */
46 #define O_NDELAY O_NONBLOCK
47 #endif
49 /* Mask for file access modes. This is system-dependent in case
50 some system ever wants to define some other flavor of access. */
51 #define O_ACCMODE (O_RDONLY|O_WRONLY|O_RDWR)
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 #define F_GETLK 5 /* Get record locking info. */
60 #define F_SETLK 6 /* Set record locking info. */
61 #define F_SETLKW 7 /* Set record locking info, wait. */
63 /* File descriptor flags used with F_GETFD and F_SETFD. */
64 #define FD_CLOEXEC 1 /* Close on exec. */
67 #include <bits/types.h>
69 /* The structure describing an advisory lock. This is the type of the third
70 argument to `fcntl' for the F_GETLK, F_SETLK, and F_SETLKW requests. */
71 struct flock
73 short int l_type; /* Type of lock: F_RDLCK, F_WRLCK, or F_UNLCK. */
74 short int l_whence; /* Where `l_start' is relative to (like `lseek'). */
75 __off_t l_start; /* Offset where the lock begins. */
76 __off_t l_len; /* Size of the locked area; zero means until EOF. */
77 short int l_sysid; /* System ID where locking process resides. */
78 short int l_pid; /* Process holding the lock. */
81 /* Values for the `l_type' field of a `struct flock'. */
82 #define F_RDLCK 1 /* Read lock. */
83 #define F_WRLCK 2 /* Write lock. */
84 #define F_UNLCK 3 /* Remove lock. */
87 /* Define some more compatibility macros to be backward compatible with
88 BSD systems which did not managed to hide these kernel macros. */
89 #ifdef __USE_BSD
90 #define FAPPEND O_APPEND
91 #define FFSYNC O_FSYNC
92 #define FNONBLOCK O_NONBLOCK
93 #define FNDELAY O_NDELAY
94 #endif /* Use BSD. */