Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ fcntl(5) — RISC iX 1.2

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

fcntl(2)

open(2)

FCNTL(5)  —  UNIX Programmer’s Manual

NAME

fcntl − file control options

SYNOPSIS

#include <fcntl.h>

DESCRIPTION

The fcntl(2) function provides for control over open files.  This include file describes requests and arguments to fcntl and open(2) as shown below:

/∗
 ∗ $Header: /smsa/bsd:usr.man/man5/fcntl.5:bsd.riscix1_2  1.4  $
 ∗ $Source: /smsa/bsd:usr.man/man5/fcntl.5: $
 ∗
 ∗ Copyright (c) 1988,1990 Acorn Computers Ltd., Cambridge, England
 ∗ Copyright (c) 1983 Regents of the University of California.
 ∗ All rights reserved.  The Berkeley software License Agreement
 ∗ specifies the terms and conditions for redistribution.
 ∗
 ∗/
#ifndef __fcntl_h
#define __fcntl_h
 #ifdef_BSD_C
#ifndef __sys_types_h
#include "sys/types.h"
#endif
#endif
 /∗ fcntl(2) requests ∗/
#defineF_DUPFD0/∗ Duplicate fildes ∗/
#defineF_GETFD1/∗ Get fildes flags ∗/
#defineF_SETFD2/∗ Set fildes flags ∗/
#defineF_GETFL3/∗ Get file flags ∗/
#defineF_SETFL4/∗ Set file flags ∗/
#defineF_GETOWN5/∗ Get owner (BSD) ∗/
#define F_SETOWN6/∗ Set owner (BSD) ∗/
#define F_GETLK7/∗ Get record-locking information ∗/
#define F_SETLK8/∗ Set or Clear a record-lock (Non-Blocking) ∗/
#define F_SETLKW9/∗ Set or Clear a record-lock (Blocking) ∗/
 /∗ fcntl() flag for F_[GS]ETFD ∗/
#defineFD_CLOEXEC1/∗ value for close-on-exec flag  ∗/
 /∗ fcntl() flags (l_type field of flock structure) ∗/
#define F_RDLCK1       /∗ read lock ∗/
#define F_WRLCK2       /∗ write lock ∗/
#define F_UNLCK3       /∗ remove lock(s) ∗/
 /∗
 ∗ The following underlying bit-positions form a complete set of file
 ∗ status flags.  Each falls into exactly one of four categories:
 ∗ (1) initialised by open(), fixed until close()
 ∗ (2) initialised by open(), modifiable by fcntl()
 ∗ (3) used only internally in the kernel
 ∗ (4) optionally set for open(), and pertaining only to the open operation
 ∗/
#define _F_READ0/∗ (1) ∗/
#define _F_WRITE1/∗ (1) ∗/
#define _F_NDELAY2/∗ (2) (obsolete) ∗/
#define _F_APPEND3/∗ (2) ∗/
#define _F_MARK4/∗ (3) ∗/
#define _F_DEFER5/∗ (3) ∗/
#define _F_ASYNC6/∗ (2) ∗/
#define _F_SHLOCK7/∗ (3) ∗/
#define _F_EXLOCK8/∗ (3) ∗/
#define _F_CREAT9/∗ (4) ∗/
#define _F_TRUNC10/∗ (4) ∗/
#define _F_EXCL11/∗ (4) ∗/
#define _F_NOCTTY12/∗ (4) ∗/
#define _F_SYNC13/∗ (2) ∗/
#define _F_NONBLOCK14/∗ (2) ∗/
 #define  _F__RW_OFFSET1/∗ kernel internal value ∗/
  /∗ Flags applicable to open ∗/
#defineO_CREAT(1 << _F_CREAT)
#define O_EXCL(1 << _F_EXCL)
#define O_NOCTTY(1 << _F_NOCTTY)
#define O_TRUNC(1 << _F_TRUNC)
/∗ Flags settable on open and fcntl ∗/
#define O_APPEND(1 << _F_APPEND)
#ifndef_POSIX_SOURCE
#define O_NDELAY(1 << _F_NDELAY)/∗ obsolete ∗/
#endif
#define O_NONBLOCK(1 << _F_NONBLOCK)/∗ new ∗/
#ifndef_POSIX_SOURCE
#define O_SYNC(1 << _F_SYNC)
#endif
#if !defined(_XOPEN_SOURCE) && !defined(_POSIX_SOURCE)
#define O_ASYNC(1 << _F_ASYNC)/∗ non-X/Open ∗/
#endif
 /∗
 ∗ File access modes for open() calls. The following 3 are funny because
 ∗ for historical reasons, open flags are known: 0 = read, 1 = write,
 ∗ 2 = read/write.
 ∗/
#define O_ACCMODE(1 << _F_READ | 1 << _F_WRITE)
#defineO_RDONLY((1 << _F_READ)  - _F__RW_OFFSET)
#defineO_WRONLY((1 << _F_WRITE) - _F__RW_OFFSET)
#defineO_RDWR((1 << _F_READ | 1 << _F_WRITE) - _F__RW_OFFSET)
  #ifdef_BSD_C
/∗ Kernel names for flags; BSD toolkit code also uses some of these. ∗/
#define FNDELAY(1 << _F_NDELAY)
#define FAPPEND(1 << _F_APPEND)
#define FASYNC(1 << _F_ASYNC)
#define FCREAT(1 << _F_CREAT)
#define FTRUNC(1 << _F_TRUNC)
#define FEXCL(1 << _F_EXCL)
#define FNOCTTY(1 << _F_NOCTTY)
#define FSYNC(1 << _F_SYNC)
#define FNONBLOCK(1 << _F_NONBLOCK)
 /∗ access(2) requests: these live in <unistd.h> for POSIX,SVID,X/Open ∗/
#defineF_OK0/∗ does file exist ∗/
#defineX_OK1/∗ is it executable by caller ∗/
#defineW_OK2/∗ writable by caller ∗/
#defineR_OK4/∗ readable by caller ∗/
 /∗ System-V record-locking options ∗/
/∗ lockf(2) requests. These live in <unistd.h> for SVID ∗/
#define F_ULOCK 0       /∗ Unlock a previously locked region ∗/
#define F_LOCK  1       /∗ Lock a region for exclusive use ∗/
#define F_TLOCK 2       /∗ Test and lock a region for exclusive use ∗/
#define F_TEST  3       /∗ Test a region for other processes locks ∗/
 #endif/∗_BSD_C∗/
  /∗ file segment locking set data type - information passed to system by user ∗/
struct flock {
        short   l_type;/∗ F_RDLCK, F_WRLCK, or F_UNLCK ∗/
        short   l_whence;/∗ flag to choose starting offset ∗/
        off_t   l_start;/∗ relative offset, in bytes ∗/
        off_t   l_len;          /∗ length, in bytes; 0 means lock to EOF ∗/
        pid_t   l_pid;/∗ returned with F_GETLK ∗/
        short   l_xxx;/∗ reserved for future use ∗/
};
 #ifndef_KERNEL
extern int creat (const char ∗ /∗path∗/, int /∗mode_t mode∗/);
extern int fcntl (int /∗fildes∗/, int /∗cmd∗/, ...);
extern int open (const char ∗ /∗path∗/, int /∗oflag∗/, ...);
#endif
 #endif/∗__fcntl_h∗/
 /∗ EOF fcntl.h ∗/

SEE ALSO

fcntl(2), open(2)

7th Edition  —  Revision 1.4 of 23/11/90

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