fcntl(5) fcntl(5)
NAME
fcntl - file control options
SYNOPSIS
#include <fcntl.h>
DESCRIPTION
The <fcntl.h> header defines the following requests and arguments for
use by the functions fcntl [see fcntl(2)] and open [see open(2)].
Values for cmd used by fcntl (the following values are unique):
F_DUPFD Duplicate file descriptor
F_GETFD Get file descriptor flags
F_SETFD Set file descriptor flags
F_GETFL Get file status flags
F_SETFL Set file status flags
F_GETLK Get record locking information
F_SETLK Set record locking information
F_SETLKW Set record locking information;
wait if blocked
F_CHKFL Unused
F_ALLOCSP Reserved
F_FREESP Free file space
F_ISSTREAM Is the file desc. a stream
F_BLOCKS Get number of BLKSIZE
blocks allocated
F_BLKSIZE Get optimal I/O block size
F_RSETLK Remote SETLK for NFS
F_RGETLK Remote GETLK for NFS
F_RSETLKW Remote SETLKW for NFS
F_GETOWN Get owner (socket emulation)
F_SETOWN Set owner (socket emulation)
File descriptor flags used for fcntl:
FD_CLOEXEC Close the file descriptor upon
execution of an exec function [see exec(2)]
Values for l_type used for record locking with fcntl
(the following values are unique):
F_RDLCK Shared or read lock
F_UNLCK Unlock
F_WRLCK Exclusive or write lock
The following three sets of values are bitwise distinct:
Values for oflag used by open:
O_CREAT Create file if it does not exist
O_EXCL Exclusive use flag
O_NOCTTY Do not assign controlling tty
O_TRUNC Truncate flag
7/91 Page 1
fcntl(5) fcntl(5)
File status flags used for open and fcntl:
O_APPEND Set append mode
O_NDELAY Non-blocking mode
O_NONBLOCK Non-blocking mode (POSIX)
O_SYNC Synchronous writes
O_PRIV Private access to file
Mask for use with file access modes:
O_ACCMODE Mask for file access modes
File access modes used for open and fcntl:
O_RDONLY Open for reading only
O_RDWR Open for reading and writing
O_WRONLY Open for writing only
The structure flock describes a file lock. It includes the following
members:
short l_type; /* Type of lock */
short l_whence; /* Flag for starting offset */
off_t l_start; /* Relative offset in bytes */
off_t l_len; /* Size; if 0 then until EOF */
pid_t l_pid; /* Returned with F_GETLK */
short l_sysid; /* Returned with F_GETLK */
SEE ALSO
creat(2), exec(2), fcntl(2), open(2).
Page 2 7/91