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_ALLOCSP           Allocate file space
         F_ALLOCSP           Allocate 64-bit file space
         F_FREESP            Free file space
         F_FREESP            Free 64-bit file space
         F_SETBSDLK          Set BSD record locking information
         F_SETBSDLKW         Set BSD record locking information;
                             wait if blocked
         F_DIOINFO           Get direct I/O parameters
         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)
         F_SETTRANSFER       Set transfer context for data pipe
         F_DESTROYTRANSFER   Destroy transfer context for data pipe
         F_ALLOCSP64         Allocate file space
         F_FREESP64          Free file space
         F_GETLK64           Get record locking information
         F_SETLK64           Set record locking information
         F_SETLKW64          Set record locking information;
                             wait if blocked
         F_RESVSP            Reserve file space
         F_UNRESVSP          Unreserve file space
         F_RESVSP64          Reserve file space
         F_UNRESVSP64        Unreserve file space
         F_FSGETXATTRA       Get extended attributes
         F_FSYNC             Flush a file range
         F_FSYNC64           Flush a 64-bit file range
         F_GETBIOSIZE        Get the preferred buffer I/O sizes
         F_SETBIOSIZE        Set the preferred buffer I/O sizes


     File descriptor flags used for fcntl:
         FD_CLOEXEC          Close the file descriptor upon
                             execution of an exec function [see exec(2)]

     File status flags used for open and fcntl:
         O_NDELAY            Non-blocking I/O
         O_APPEND            Append
         O_SYNC              Synchronous write option
         O_DSYNC             Synchronous write option for data
         O_RSYNC             Synchronous data integrity read
         FASYNC              Interrupt-driven I/O for sockets
         O_NONBLOCK          Non-blocking I/O
         O_LCFLUSH           Flush cache on last close
         O_LCINVAL           Flush and invalidate cache on last close

     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

     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
         O_DIRECT            Direct I/O
         O_LARGEFILE         Allow large file opens

     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 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 S_ISUID     /* set user id on execution */
          #define S_ISGID     /* set group id on execution */
          #define S_IRWXU     /* read, write, execute: owner */
          #define S_IRUSR     /* read permission: owner */
          #define S_IWUSR     /* write permission: owner */
          #define S_IXUSR     /* execute permission: owner */
          #define S_IRWXG     /* read, write, execute: group */
          #define S_IRGRP     /* read permission: group */
          #define S_IWGRP     /* write permission: group */
          #define S_IXGRP     /* execute permission: group */
          #define S_IRWXO     /* read, write, execute: other */


          #define S_IROTH     /* read permission: other */
          #define S_IWOTH     /* write permission: other */
          #define S_IXOTH     /* 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 SEEK_SET     /* Set file pointer to "offset" */
          #define SEEK_CUR     /* Set file pointer to current plus"offset" */
          #define SEEK_END     /* 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