F_GETFL2const
Get/set file status flags
Usage
#include <fcntl.h>
int fcntl(int fd, F_GETFL); int fcntl(int fd, F_SETFL, int arg);
Library
Standard C library (libc, -lc)
Overview
Each open file description has certain associated status flags, initialized by open(2) and possibly modified by fcntl(2). Duplicated file descriptors (made with dup(2), F_DUPFD(2const), fork(2), etc.) refer to the same open file description, and thus share the same file status flags.
The file status flags and their semantics are described in open(2).
F_GETFL-
Return (as the function result) the file access mode and the file status flags; arg is ignored.
F_SETFL-
Set the file status flags to the value specified by arg. File access mode (
O_RDONLY,O_WRONLY,O_RDWR) and file creation flags (i.e.,O_CREAT,O_EXCL,O_NOCTTY,O_TRUNC) in arg are ignored. On Linux, this operation can change only theO_APPEND,O_ASYNC,O_DIRECT,O_NOATIME, andO_NONBLOCKflags. It is not possible to change theO_DSYNCandO_SYNCflags; see BUGS, below.
Return value
|
Value of file status flags. |
|---|---|
|
Zero. |
On error, -1 is returned, and errno is set to indicate the error.
Errors
See fcntl(2).
- EPERM
-
Attempted to clear the
O_APPENDflag on a file that has the append-only attribute set.