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):
FDUPFD Duplicate file descriptor
FGETFD Get file descriptor flags
FSETFD Set file descriptor flags
FGETFL Get file status flags
FSETFL Set file status flags
FGETLK Get record locking information
FSETLK Set record locking information
FSETLKW Set record locking information;
wait if blocked
FALLOCSP Allocate file space
FALLOCSP Allocate 64-bit file space
FFREESP Free file space
FFREESP Free 64-bit file space
FSETBSDLK Set BSD record locking information
FSETBSDLKW Set BSD record locking information;
wait if blocked
FDIOINFO Get direct I/O parameters
FRSETLK Remote SETLK for NFS
FRGETLK Remote GETLK for NFS
FRSETLKW Remote SETLKW for NFS
FGETOWN Get owner (socket emulation)
FSETOWN Set owner (socket emulation)
FSETTRANSFER Set transfer context for data pipe
FDESTROYTRANSFER Destroy transfer context for data pipe
FALLOCSP64 Allocate file space
FFREESP64 Free file space
FGETLK64 Get record locking information
FSETLK64 Set record locking information
FSETLKW64 Set record locking information;
wait if blocked
FRESVSP Reserve file space
FUNRESVSP Unreserve file space
FRESVSP64 Reserve file space
FUNRESVSP64 Unreserve file space
FFSGETXATTRA Get extended attributes
FFSYNC Flush a file range
FFSYNC64 Flush a 64-bit file range
FGETBIOSIZE Get the preferred buffer I/O sizes
FSETBIOSIZE Set the preferred buffer I/O sizes
Page 1
fcntl(5) fcntl(5)
File descriptor flags used for fcntl:
FDCLOEXEC Close the file descriptor upon
execution of an exec function [see exec(2)]
File status flags used for open and fcntl:
ONDELAY Non-blocking I/O
OAPPEND Append
OSYNC Synchronous write option
ODSYNC Synchronous write option for data
ORSYNC Synchronous data integrity read
FASYNC Interrupt-driven I/O for sockets
ONONBLOCK Non-blocking I/O
OLCFLUSH Flush cache on last close
OLCINVAL Flush and invalidate cache on last close
Values for l_type used for record locking with fcntl
(the following values are unique):
FRDLCK Shared or read lock
FUNLCK Unlock
FWRLCK Exclusive or write lock
Values for oflag used by open:
OCREAT Create file if it does not exist
OEXCL Exclusive use flag
ONOCTTY Do not assign controlling tty
OTRUNC Truncate flag
ODIRECT Direct I/O
OLARGEFILE Allow large file opens
Mask for use with file access modes:
OACCMODE Mask for file access modes
File access modes used for open and fcntl:
ORDONLY Open for reading only
ORDWR Open for reading and writing
OWRONLY Open for writing only
The constants used for file modes are defined to have the same values as
in sys/stat.h. These constants exist in fcntl.h also in order to comply
with the XPG4 standards.
#define SISUID /* set user id on execution */
#define SISGID /* set group id on execution */
#define SIRWXU /* read, write, execute: owner */
#define SIRUSR /* read permission: owner */
#define SIWUSR /* write permission: owner */
#define SIXUSR /* execute permission: owner */
#define SIRWXG /* read, write, execute: group */
#define SIRGRP /* read permission: group */
#define SIWGRP /* write permission: group */
#define SIXGRP /* execute permission: group */
#define SIRWXO /* read, write, execute: other */
Page 2
fcntl(5) fcntl(5)
#define SIROTH /* read permission: other */
#define SIWOTH /* write permission: other */
#define SIXOTH /* execute permission: other */
The constants used for the lseek routine are defined to have the same
values as in unistd.h. These constants exist in fcntl.h also in order to
comply with the XPG4 standards.
#define SEEKSET /* Set file pointer to "offset" */
#define SEEKCUR /* Set file pointer to current plus"offset" */
#define SEEKEND /* Set file pointer to EOF plus"offset" */
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 */
long l_sysid; /* Returned with F_GETLK */
pid_t l_pid; /* Returned with F_GETLK */
The structure flock64 describes a file lock for use on large files. It
includes the following members:
short l_type; /* Type of lock */
short l_whence; /* Flag for starting offset */
off64_t l_start; /* Relative offset in bytes */
off64_t l_len; /* Size; if 0 then until EOF */
long l_sysid; /* Returned with F_GETLK */
pid_t l_pid; /* Returned with F_GETLK */
The structure biosize is used to pass information about the preferred I/O
sizes used for a file. It contains the following members:
__uint32_t biosz_flags; /* 1 if defaults are overridden */
__int32_t biosz_read; /* all values specified as log */
__int32_t biosz_write; /* base2 of the true length */
__int32_t dfl_biosz_read; /* Returned with F_GETBIOSIZE */
__int32_t dfl_biosz_write; /* Returned with F_GETBIOSIZE */
SEE ALSO
creat(2), exec(2), fcntl(2), open(2)
Page 3