1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108
|
.\" Copyright, the authors of the Linux man-pages project
.\"
.\" SPDX-License-Identifier: Linux-man-pages-copyleft
.\"
.TH F_GETFL 2const 2025-07-20 "Linux man-pages (unreleased)"
.SH NAME
F_GETFL,
F_SETFL
\-
get/set file status flags
.SH LIBRARY
Standard C library
.RI ( libc ,\~ \-lc )
.SH SYNOPSIS
.nf
.B #include <fcntl.h>
.P
.BI "int fcntl(int " fd ", F_GETFL);"
.BI "int fcntl(int " fd ", F_SETFL, int " arg );
.fi
.SH DESCRIPTION
Each open file description has certain associated status flags,
initialized by
.BR open (2)
.\" or
.\" .BR creat (2),
and possibly modified by
.BR fcntl (2).
Duplicated file descriptors
(made with
.BR dup (2),
.BR F_DUPFD (2const),
.BR fork (2),
etc.) refer to the same open file description, and thus
share the same file status flags.
.P
The file status flags and their semantics are described in
.BR open (2).
.TP
.B F_GETFL
Return (as the function result)
the file access mode and the file status flags;
.I arg
is ignored.
.TP
.B F_SETFL
Set the file status flags to the value specified by
.IR arg .
File access mode
.RB ( O_RDONLY ", " O_WRONLY ", " O_RDWR )
and file creation flags
(i.e.,
.BR O_CREAT ", " O_EXCL ", " O_NOCTTY ", " O_TRUNC )
in
.I arg
are ignored.
On Linux, this operation can change only the
.BR O_APPEND ,
.BR O_ASYNC ,
.BR O_DIRECT ,
.BR O_NOATIME ,
and
.B O_NONBLOCK
flags.
It is not possible to change the
.B O_DSYNC
and
.B O_SYNC
flags; see BUGS, below.
.SH RETURN VALUE
.TP
.B F_GETFL
Value of file status flags.
.TP
.B F_SETFL
Zero.
.P
On error, \-1 is returned, and
.I errno
is set to indicate the error.
.SH ERRORS
See
.BR fcntl (2).
.TP
.B EPERM
Attempted to clear the
.B O_APPEND
flag on a file that has the append-only attribute set.
.SH STANDARDS
POSIX.1-2008.
.SH HISTORY
SVr4, 4.3BSD, POSIX.1-2001.
.SH BUGS
.SS F_SETFL
It is not possible to use
.B F_SETFL
to change the state of the
.B O_DSYNC
and
.B O_SYNC
flags.
.\" FIXME . According to POSIX.1-2001, O_SYNC should also be modifiable
.\" via fcntl(2), but currently Linux does not permit this
.\" See http://bugzilla.kernel.org/show_bug.cgi?id=5994
Attempts to change the state of these flags are silently ignored.
.SH SEE ALSO
.BR fcntl (2),
.BR open (2)
|