home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 8 / FreshFishVol8-CD1.bin / gnu / man / cat2 / open.0 < prev    next >
Text File  |  1993-12-07  |  7KB  |  199 lines

  1.  
  2. OPEN(2)                    UNIX Programmer's Manual                    OPEN(2)
  3.  
  4. NNAAMMEE
  5.      ooppeenn - open or create a file for reading or writing
  6.  
  7. SSYYNNOOPPSSIISS
  8.      ##iinncclluuddee <<ssyyss//ffiillee..hh>>
  9.  
  10.      _i_n_t
  11.      ooppeenn(_c_o_n_s_t _c_h_a_r _*_p_a_t_h, _i_n_t _f_l_a_g_s, _m_o_d_e___t _m_o_d_e)
  12.  
  13. DDEESSCCRRIIPPTTIIOONN
  14.      The file name specified by _p_a_t_h is opened for reading and/or writing as
  15.      specified by the argument _f_l_a_g_s and the file descriptor returned to the
  16.      calling process.  The _f_l_a_g_s argument may indicate the file is to be cre­
  17.      ated if it does not exist (by specifying the O_CREAT flag), in which case
  18.      the file is created with mode _m_o_d_e as described in chmod(2) and modified
  19.      by the process' umask value (see umask(2)).
  20.  
  21.      The flags specified are formed by _o_r'ing the following values
  22.  
  23.            O_RDONLY        open for reading only
  24.            O_WRONLY        open for writing only
  25.            O_RDWR          open for reading and writing
  26.            O_NONBLOCK      do not block on open
  27.            O_APPEND        append on each write
  28.            O_CREAT         create file if it does not exist
  29.            O_TRUNC         truncate size to 0
  30.            O_EXCL          error if create and file exists
  31.            O_SHLOCK        atomically obtain a shared lock
  32.            O_EXLOCK        atomically obtain an exclusive lock
  33.  
  34.      Opening a file with O_APPEND set causes each write on the file to be ap­
  35.      pended to the end.  If O_TRUNC is specified and the file exists, the file
  36.      is truncated to zero length.  If O_EXCL is set with O_CREAT and the file
  37.      already exists, ooppeenn() returns an error.  This may be used to implement a
  38.      simple exclusive access locking mechanism.  If O_EXCL is set and the last
  39.      component of the pathname is a symbolic link, ooppeenn() will fail even if
  40.      the symbolic link points to a non­existent name.  If the O_NONBLOCK flag
  41.      is specified and the ooppeenn() call would result in the process being
  42.      blocked for some reason (e.g., waiting for carrier on a dialup line),
  43.      ooppeenn() returns immediately.  The first time the process attempts to per­
  44.      form I/O on the open file it will block (not currently implemented).
  45.  
  46.      When opening a file, a lock with flock(2) semantics can be obtained by
  47.      setting O_SHLOCK for a shared lock, or O_EXLOCK for an exclusive lock.
  48.      If creating a file with O_CREAT, the request for the lock will never fail
  49.      (provided that the underlying filesystem supports locking).
  50.  
  51.      If successful, ooppeenn() returns a non­negative integer, termed a file de­
  52.      scriptor.  It returns ­1 on failure.  The file pointer used to mark the
  53.      current position within the file is set to the beginning of the file.
  54.  
  55.      The new descriptor is set to remain open across execve system calls; see
  56.      close(2) and fcntl(2).
  57.  
  58.      The system imposes a limit on the number of file descriptors open simul­
  59.      taneously by one process.  Getdtablesize(2) returns the current system
  60.      limit.
  61.  
  62. EERRRROORRSS
  63.      The named file is opened unless:
  64.  
  65.  
  66.      [ENOTDIR]     A component of the path prefix is not a directory.
  67.  
  68.      [ENAMETOOLONG]
  69.                    A component of a pathname exceeded 255 characters, or an
  70.                    entire path name exceeded 1023 characters.
  71.  
  72.      [ENOENT]      O_CREAT is not set and the named file does not exist.
  73.  
  74.      [ENOENT]      A component of the path name that must exist does not ex­
  75.                    ist.
  76.  
  77.      [EACCES]      Search permission is denied for a component of the path
  78.                    prefix.
  79.  
  80.      [EACCES]      The required permissions (for reading and/or writing) are
  81.                    denied for the given flags.
  82.  
  83.      [EACCES]      O_CREAT is specified, the file does not exist, and the di­
  84.                    rectory in which it is to be created does not permit writ­
  85.                    ing.
  86.  
  87.      [ELOOP]       Too many symbolic links were encountered in translating the
  88.                    pathname.
  89.  
  90.      [EISDIR]      The named file is a directory, and the arguments specify it
  91.                    is to be opened for writing.
  92.  
  93.      [EROFS]       The named file resides on a read­only file system, and the
  94.                    file is to be modified.
  95.  
  96.      [EMFILE]      The process has already reached its limit for open file de­
  97.                    scriptors.
  98.  
  99.      [ENFILE]      The system file table is full.
  100.  
  101.      [ENXIO]       The named file is a character special or block special
  102.                    file, and the device associated with this special file does
  103.                    not exist.
  104.  
  105.      [EINTR]       The ooppeenn operation was interrupted by a signal.
  106.  
  107.      [EOPNOTSUPP]  O_SHLOCK or O_EXLOCK is specified but the underlying
  108.                    filesystem does not support locking.
  109.  
  110.      [ENOSPC]      O_CREAT is specified, the file does not exist, and the di­
  111.                    rectory in which the entry for the new file is being placed
  112.                    cannot be extended because there is no space left on the
  113.                    file system containing the directory.
  114.  
  115.      [ENOSPC]      O_CREAT is specified, the file does not exist, and there
  116.                    are no free inodes on the file system on which the file is
  117.                    being created.
  118.  
  119.      [EDQUOT]      O_CREAT is specified, the file does not exist, and the di­
  120.                    rectory in which the entry for the new file is being placed
  121.                    cannot be extended because the user's quota of disk blocks
  122.                    on the file system containing the directory has been ex­
  123.                    hausted.
  124.  
  125.      [EDQUOT]      O_CREAT is specified, the file does not exist, and the us­
  126.                    er's quota of inodes on the file system on which the file
  127.                    is being created has been exhausted.
  128.  
  129.      [EIO]         An I/O error occurred while making the directory entry or
  130.  
  131.  
  132.                    allocating the inode for O_CREAT.
  133.  
  134.      [ETXTBSY]     The file is a pure procedure (shared text) file that is be­
  135.                    ing executed and the ooppeenn() call requests write access.
  136.  
  137.      [EFAULT]      _P_a_t_h points outside the process's allocated address space.
  138.  
  139.      [EEXIST]      O_CREAT and O_EXCL were specified and the file exists.
  140.  
  141.      [EOPNOTSUPP]  An attempt was made to open a socket (not currently imple­
  142.                    mented).
  143.  
  144. SSEEEE AALLSSOO
  145.      chmod(2),  close(2),  dup(2),  getdtablesize(2),  lseek(2),  read(2),
  146.      write(2),  umask(2)
  147.  
  148. HHIISSTTOORRYY
  149.      An ooppeenn function call appeared in Version 6 AT&T UNIX.
  150.  
  151. 4th Berkeley Distribution        May 27, 1991                                3
  152.  
  153.  
  154.  
  155.  
  156.  
  157.  
  158.  
  159.  
  160.  
  161.  
  162.  
  163.  
  164.  
  165.  
  166.  
  167.  
  168.  
  169.  
  170.  
  171.  
  172.  
  173.  
  174.  
  175.  
  176.  
  177.  
  178.  
  179.  
  180.  
  181.  
  182.  
  183.  
  184.  
  185.  
  186.  
  187.  
  188.  
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195.  
  196.  
  197.  
  198.  
  199.