.\" 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 6.15" .SH NAME F_GETFL, F_SETFL \- get/set file status flags .SH LIBRARY Standard C library .RI ( libc ,\~ \-lc ) .SH SYNOPSIS .nf .B #include .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)