Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ open(2) — A/UX 0.7

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

chmod(2)

close(2)

creat(2)

fcntl(2)

lseek(2)

read(2)

umask(2)

write(2)



     open(2)                                                   open(2)



     NAME
          open - open for reading or writing

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

     DESCRIPTION
          path points to a path name 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 or-ing flags from the following list (only
          one of the first three flags below may be used):

          ORDONLY Open for reading only.

          OWRONLY Open for writing only.

          ORDWR   Open for reading and writing.

          ONDELAY This flag may affect subsequent reads and writes.
                   See read(2) and write(3).

                   When opening a FIFO with ORDONLY or OWRONLY set:

                   If ONDELAY 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 ONDELAY 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 ONDELAY is set:

                        The open will return without waiting for
                        carrier.

                   If ONDELAY is clear:

                        The open will block until carrier is present.



     Page 1                                        (last mod. 1/14/87)





     open(2)                                                   open(2)



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

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

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

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

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

          OEXCL   If OEXCL and OCREAT are set, open will fail if
                   the file exists.

          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(2).

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

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

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

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

          [EACCES]       oflag permission is denied for the named
                         file.

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

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

          [EMFILE]       Twenty (20) file descriptors are currently
                         open.



     Page 2                                        (last mod. 1/14/87)





     open(2)                                                   open(2)



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

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

                         Note: If you are running an NFS system and
                         you are accessing a shared binary remotely,
                         it is possible that you will not get this
                         errno.

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

          [EEXIST]       OCREAT and OEXCL are set, and the named
                         file exists.

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

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

          [ENFILE]       The system file table is full.

     RETURN VALUE
          Upon successful completion, the file descriptor is returned.
          Otherwise, a value of -1 is returned and errno is set to
          indicate the error.

     SEE ALSO
          chmod(2), close(2), creat(2), fcntl(2), lseek(2), read(2),
          umask(2), write(2).



















     Page 3                                        (last mod. 1/14/87)



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