Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ open(S) — Xenix 2.3.4g

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

chmod(S)

close(S)

creat(S)

dup(S)

fcntl(S)

lseek(S)

read(S)

umask(S)

write(S)



     OPEN(S)                  XENIX System V                   OPEN(S)



     Name
          open - Opens file for reading or writing.

     Syntax
          #include <fcntl.h>
          int open (path, oflag[, mode])
          char *path;
          int oflag, mode;

     Description
          path points to a pathname naming a file.  open opens a file
          descriptor for the named file and sets the file status flags
          according to the value of oflag.  oflag values are
          constructed by using flags from the following list (only one
          of the first three flags below may be used):

          O_RDONLY Open for reading only.

          O_WRONLY Open for writing only.

          O_RDWR   Open for reading and writing.

          O_NDELAY This flag may affect subsequent reads and writes.
                   See read(S) and write(S).

                   When opening a FIFO with O_RDONLY or O_WRONLY set:

                   If O_NDELAY is set:

                        An open for reading-only will return without
                        delay.  An open for writing-only will return
                        an error if no process currently has the file
                        open for reading.

                   If O_NDELAY is clear:

                        An open for reading-only will block until a
                        process opens the file for writing.  An open
                        for writing-only will block until a process
                        opens the file for reading.

                   When opening a file associated with a communication
                   line:

                   If O_NDELAY is set:

                        The open will return without waiting for
                        carrier.

                   If O_NDELAY is clear:

                        The open will block until carrier is present.



     Page 1                                           (printed 8/7/87)





     OPEN(S)                  XENIX System V                   OPEN(S)



          O_APPEND If set, the file pointer will be set to the end of
                   the file prior to each write.

          O_CREAT  If the file exists, this flag has no effect.
                   Otherwise, the file's owner ID is set to the
                   process' effective user ID, the file's group ID is
                   set to the process' effective group ID, and the
                   low-order 12 bits of the file mode are set to the
                   value of mode modified as follows (see creat(S)):

                        All bits set in the process' file mode
                        creation mask are cleared.  See umask(S).

                        The ``save text image after execution bit'' of
                        the mode is cleared.  See chmod(S).

          O_TRUNC  If the file exists, its length is truncated to 0
                   and the mode and owner are unchanged.

          O_EXCL   If O_EXCL and O_CREAT are set, open will fail if
                   the file exists.

          O_SYNCW  Every write to this file descriptor will be
                   synchronous, that is, when the write system call
                   completes, data is guaranteed to have been written
                   to disk.

          Upon successful completion, a nonnegative integer, the file
          descriptor, is returned.

          The file pointer used to mark the current position within
          the file is set to the beginning of the file.

          The new file descriptor is set to remain open across exec
          system calls.  See fcntl(S).

          No process may have more than 60 file descriptors open
          simultaneously.

          The named file is opened unless one or more of the following
          are true:

               A component of the path prefix is not a directory.
               [ENOTDIR]

               O_CREAT is not set and the named file does not exist.
               [ENOENT]

               A component of the path prefix denies search
               permission.  [EACCES]

               oflag permission is denied for the named file.



     Page 2                                           (printed 8/7/87)





     OPEN(S)                  XENIX System V                   OPEN(S)



               [EACCES]

               The named file is a directory and oflag is write or
               read/write.  [EISDIR]

               The named file resides on a read-only file system and
               oflag is write or read/write.  [EROFS]

               Sixty file descriptors are currently open.  [EMFILE]

               The named file is a character special or block special
               file, and the device associated with this special file
               does not exist.  [ENXIO]

               The file is a pure procedure (shared text) file that is
               being executed and oflag is write or read/write.
               [ETXTBSY]

               path points outside the process' allocated address
               space.  [EFAULT]

               O_CREAT and O_EXCL are set, and the named file exists.
               [EEXIST]

               O_NDELAY is set, the named file is a FIFO, O_WRONLY is
               set, and no process has the file open for reading.
               [ENXIO]

               A signal was caught during the open system call.
               [EINTR]

               The system file table is full.  [ENFILE]

               The directory to contain the file cannot be extended,
               the file does not exist, and O_CREAT is specified.
               [ENOSPC]

     Return Value
          Upon successful completion, a nonnegative integer, namely a
          file descriptor, is returned.  Otherwise, a value of -1 is
          returned and errno is set to indicate the error.

     See Also
          chmod(S), close(S), creat(S), dup(S), fcntl(S), lseek(S),
          read(S), umask(S), write(S)

     Notes
          The O_SYNCHW flag is a XENIX specific enhancement which may
          not be present in all UNIX implementations.






     Page 3                                           (printed 8/7/87)



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