Annotation of cci/usr/src/man/man2/open.2, revision 1.1

1.1     ! root        1: .TH OPEN 2 "2 July 1983"
        !             2: .UC 4
        !             3: .SH NAME
        !             4: open \- open a file for reading or writing, or create a new file
        !             5: .SH SYNOPSIS
        !             6: .nf
        !             7: .ft B
        !             8: #include <sys/file.h>
        !             9: .PP
        !            10: .ft B
        !            11: open(path, flags, mode)
        !            12: char *path;
        !            13: int flags, mode;
        !            14: .fi
        !            15: .SH DESCRIPTION
        !            16: .I Open
        !            17: opens the file
        !            18: .I path
        !            19: for reading and/or writing, as specified by the
        !            20: .I flags
        !            21: argument and returns a descriptor for that file.
        !            22: The
        !            23: .I flags
        !            24: argument may indicate the file is to be
        !            25: created if it does not already exist (by specifying the
        !            26: O_CREAT flag), in which case the file is created with mode
        !            27: .I mode
        !            28: as described in
        !            29: .IR chmod (2)
        !            30: and modified by the process' umask value (see
        !            31: .IR umask (2)).
        !            32: .PP
        !            33: .I Path
        !            34: is the address of a string of ASCII characters representing
        !            35: a path name, terminated by a null character.
        !            36: The flags specified are formed by
        !            37: .IR or 'ing
        !            38: the following values
        !            39: .PP
        !            40: .RS
        !            41:  O_RDONLY      open for reading only
        !            42:  O_WRONLY      open for writing only
        !            43:  O_RDWR        open for reading and writing
        !            44:  O_NDELAY      do not block on open
        !            45:  O_APPEND      append on each write
        !            46:  O_CREAT       create file if it does not exist
        !            47:  O_TRUNC       truncate size to 0
        !            48:  O_EXCL        error if create and file exists
        !            49: .RE
        !            50: .PP
        !            51: Opening a file with O_APPEND set causes each write on the file
        !            52: to be appended to the end.  If O_TRUNC is specified and the
        !            53: file exists, the file is truncated to zero length.
        !            54: If O_EXCL is set with O_CREAT, then if the file already
        !            55: exists, the open returns an error.  This can be used to
        !            56: implement a simple exclusive access locking mechanism.
        !            57: If the O_NDELAY flag is specified and the open call would result
        !            58: in the process being blocked for some reason (e.g. waiting for
        !            59: carrier on a dialup line), the open returns immediately. 
        !            60: The first time the process attempts to perform i/o on the open
        !            61: file it will block (not currently implemented).
        !            62: .PP
        !            63: Upon successful completion a non-negative integer termed a
        !            64: file descriptor is returned.
        !            65: The file pointer used to mark the current position within the
        !            66: file is set to the beginning of the file.
        !            67: .PP
        !            68: The new descriptor is set to remain open across
        !            69: .IR execve
        !            70: system calls; see
        !            71: .IR close (2).
        !            72: .PP
        !            73: No process may have more than {OPEN_MAX} file descriptors open
        !            74: simultaneously.
        !            75: .SH "ERRORS
        !            76: The named file is opened unless one or more of the
        !            77: following are true:
        !            78: .TP 15
        !            79: [EPERM]
        !            80: The pathname contains a character with the high-order bit set.
        !            81: .TP 15
        !            82: [ENOTDIR]
        !            83: A component of the path prefix is not a directory.
        !            84: .TP 15
        !            85: [ENOENT]
        !            86: O_CREAT is not set and the named file does not exist.
        !            87: .TP 15
        !            88: [EACCES]
        !            89: A component of the path prefix denies search permission.
        !            90: .TP 15
        !            91: [EACCES]
        !            92: The required permissions (for reading and/or writing)
        !            93: are denied for the named flag.
        !            94: .TP 15
        !            95: [EISDIR]
        !            96: The named file is a directory, and the arguments specify
        !            97: it is to be opened for writting.
        !            98: .TP 15
        !            99: [EROFS]
        !           100: The named file resides on a read-only file system,
        !           101: and the file is to be modified.
        !           102: .TP 15
        !           103: [EMFILE]
        !           104: {OPEN_MAX} file descriptors are currently open.
        !           105: .TP 15
        !           106: [ENXIO]
        !           107: The named file is a character special or block
        !           108: special file, and the device associated with this special file
        !           109: does not exist.
        !           110: .TP 15
        !           111: [ETXTBSY]
        !           112: The file is a pure procedure (shared text) file that is being
        !           113: executed and the \fIopen\fP call requests write access.
        !           114: .TP 15
        !           115: [EFAULT]
        !           116: .I Path
        !           117: points outside the process's allocated address space.
        !           118: .TP 15
        !           119: [ELOOP]
        !           120: Too many symbolic links were encountered in translating the pathname.
        !           121: .TP 15
        !           122: [EEXIST]
        !           123: O_EXCL was specified and the file exists.
        !           124: .TP 15
        !           125: [ENXIO]
        !           126: The O_NDELAY flag is given, and the file is a communications device
        !           127: on which their is no carrier present.
        !           128: .TP 15
        !           129: [EOPNOTSUPP]
        !           130: An attempt was made to open a socket (not currently implemented).
        !           131: .SH "SEE ALSO"
        !           132: chmod(2), close(2), dup(2), lseek(2), read(2), write(2), umask(2)

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.