1 /* Copyright (C) 1991, 1992 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public License as
6 published by the Free Software Foundation; either version 2 of the
7 License, or (at your option) any later version.
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
14 You should have received a copy of the GNU Library General Public
15 License along with the GNU C Library; see the file COPYING.LIB. If
16 not, write to the Free Software Foundation, Inc., 675 Mass Ave,
17 Cambridge, MA 02139, USA. */
20 * POSIX Standard: 6.5 File Control Operations <fcntl.h>
28 #include <fcntlbits.h>
32 /* Values for the second argument to fcntl. */
33 #define F_DUPFD __F_DUPFD /* Duplicate file descriptor. */
34 #define F_GETFD __F_GETFD /* Get file descriptor flags. */
35 #define F_SETFD __F_SETFD /* Set file descriptor flags. */
36 #define F_GETFL __F_GETFL /* Get file status flags. */
37 #define F_SETFL __F_SETFL /* Set file status flags. */
38 #define F_GETLK __F_GETLK /* Get record locking info. */
39 #define F_SETLK __F_SETLK /* Set record locking info. */
40 #define F_SETLKW __F_SETLKW /* Set record locking, block. */
43 #define F_GETOWN __F_GETOWN /* Get owner (receiver of SIGIO). */
44 #define F_SETOWN __F_SETOWN /* Set owner (receiver of SIGIO). */
48 /* File descriptor flags used with F_GETFD and F_SETFD. */
49 #define FD_CLOEXEC __FD_CLOEXEC /* Close on exec. */
52 /* File access modes for open and fcntl. */
53 #define O_RDONLY __O_RDONLY /* Open read-only. */
54 #define O_WRONLY __O_WRONLY /* Open write-only. */
55 #define O_RDWR __O_RDWR /* Open read/write. */
58 /* Bits OR'd into the second argument to open. */
59 #define O_CREAT __O_CREAT /* Create file if it doesn't exist. */
60 #define O_EXCL __O_EXCL /* Fail if file already exists. */
61 #define O_TRUNC __O_TRUNC /* Truncate file to zero length. */
62 #define O_NOCTTY __O_NOCTTY /* Don't assign a controlling tty. */
65 /* File status flags for `open' and `fcntl'. */
66 #define O_APPEND __O_APPEND /* Writes append to the file. */
67 #define O_NONBLOCK __O_NONBLOCK /* No delay when opening the file. */
70 #define O_NDELAY __O_NDELAY
74 /* Unix-style flags for `fcntl' F_GETFL and F_SETFL. */
75 #define FREAD 0x1 /* Read access. */
76 #define FWRITE 0x2 /* Write access. */
77 #define FNDELAY O_NONBLOCK
78 #define FAPPEND O_APPEND
79 #define FASYNC 0x40 /* Send SIGIO when data is ready. */
80 #define FCREAT O_CREAT
81 #define FTRUNC O_TRUNC
83 #define FSYNC 0x2000 /* Synchronous writes. */
85 #ifndef R_OK /* Verbatim from <unistd.h>. Ugh. */
86 /* Values for the second argument to access.
87 These may be OR'd together. */
88 #define R_OK 4 /* Test for read permission. */
89 #define W_OK 2 /* Test for write permission. */
90 #define X_OK 1 /* Test for execute permission. */
91 #define F_OK 0 /* Test for existence. */
93 #endif /* Use misc. */
96 /* Mask for file access modes. */
97 #define O_ACCMODE __O_ACCMODE
100 /* Do the file control operation described by CMD on FD.
101 The remaining arguments are interpreted depending on CMD. */
102 extern int EXFUN(__fcntl, (int __fd, int __cmd, ...));
104 /* Open FILE and return a new file descriptor for it, or -1 on error.
105 OFLAG determines the type of access used. If O_CREAT is on OFLAG,
106 the third argument is taken as a `mode_t', the mode of the created file. */
107 extern int EXFUN(__open, (CONST char *__file, int __oflag, ...));
109 #define fcntl __fcntl
112 /* Create and open FILE, with mode MODE.
113 This takes an `int' MODE argument because that is
114 what `mode_t' will be widened to. */
115 extern int EXFUN(creat, (CONST char *__file, __mode_t __mode));
118 #define creat(file, m) __open((file), O_WRONLY|O_CREAT|O_TRUNC, (m))
119 #endif /* Optimizing. */
121 #define flock __flock
122 #define F_RDLCK __F_RDLCK
123 #define F_WRLCK __F_WRLCK
124 #define F_UNLCK __F_UNLCK