Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

fcntl(2)

open(2)

read(2)

write(2)



  fcntl(0)                            CLIX                            fcntl(0)



  NAME

    fcntl - File control options

  SYNOPSIS

    #include <fcntl.h>

    #include <file.h>

  DESCRIPTION

    The fcntl() function provides for control over open files.  These #include
    files describe commands and arguments to the fcntl() and open() functions.

    The following are flag values accessible to the open() and fcntl()
    functions.  (The first three can be set only by the open() function.)

    #define O_RDONLY   0
           Opens file for reading only.

    #define O_WRONLY   1
           Opens file for writing only.

    #define O_RDWR     2
           Opens file for reading and writing.

    #define O_ACCMODE  3
           POSIX mask for file access modes.

    #define O_NDELAY   04
           Nonblocking I/O.  This flag may affect subsequent reads and writes.
           (See the read() and write() functions.)

    #define O_APPEND   010
           Appends (writes guaranteed at the end).  If set, the file pointer
           is set to the end of the file prior to each write.

    #define O_SYNC     020
           Synchronous write option.  When opening a regular file, this flag
           affects subsequent writes.  If set, each write() function call
           waits for both the file data and file status to be physically
           updated.

    #define O_NONBLOCK 0100
           POSIX nonblocking I/O.  This flag may affect subsequent reads and
           writes.  (See the read() and write() functions.)

    The following flag values are accessible only to the open() function.

    #define O_CREAT    00400



  2/94 - Intergraph Corporation                                              1






  fcntl(0)                            CLIX                            fcntl(0)



           If the file exists, this flag has no effect, except as noted under
           O_EXCL in open(2).  If the file does not exist, it is opened with
           file create (uses third open arg).

    #define O_TRUNC    01000
           Opens with truncation.  If the file exists, its length is truncated
           to 0 and the mode and owner are unchanged.

    #define O_EXCL     02000
           Exclusive open.  If O_EXCL and O_CREAT are set, the open() function
           fails if the file exists.

    The following flag values are accessible only to the fcntl() function.

    #define FASYNC     0x8000
           Enables the SIGIO signal.

    #define F_DUPFD    0
           Duplicates fildes.

    #define F_GETFD    1
           Gets fildes flags.

    #define F_SETFD    2
           Sets fildes flags.

    #define F_GETFL    3
           Gets file flags.

    #define F_SETFL    4
           Sets file flags.

    #define F_GETLK    5
           Gets file lock.

    #define F_SETLK    6
           Sets file lock.

    #define F_SETLKW   7
           Sets file lock and waits.

    #define F_CHKFL    8
           Checks legality of file flag changes.

    #define FD_CLOEXEC 1
           POSIX close on the exec() function.

    #define F_SETOWN   126
           Sets to receive signals.

    #define F_GETOWN   127



  2                                              Intergraph Corporation - 2/94






  fcntl(0)                            CLIX                            fcntl(0)



           Gets ID of signal receiver.

    The following defines the file segment locking control structure:

    short l_type
           Specifies the action to take (see types below).

    short l_whence
           Specifies the starting byte offset of the range to be locked.  (See
           the lseek() function.)  In summary:

           i_whence   Starting Address
           ________   _____________________________
              0       l_start
              1       Current file offset + l_start
              2       End-of-file + l_start

    long l_start
           See the list above.

    long l_len
           Length of range to be locked; 0 specifies until EOF.

    short l_sysid
           Returned with F_GETLK.  F_GETLK fills in this field with
           information about which process currently holds a lock that blocks
           the lock specified.  The l_sysid member is the RFS system ID, which
           is typically ignored.

    short l_pid
           Returned with F_GETLK.  F_GETLK fills-in this field with
           information about which process currently holds a lock that blocks
           the lock specified.  The l_pid member is the process ID of the
           process holding the lock.

    File segment locking types:

    #define F_RDLCK    01
           Sets a read lock.

    #define F_WRLCK    02
           Sets a write lock.

    #define F_UNLCK    03
           Removes locks.

  RELATED INFORMATION

    Functions:  fcntl(2), open(2), read(2), write(2)





  2/94 - Intergraph Corporation                                              3




Typewritten Software • bear@typewritten.org • Edmonds, WA 98026