Switch to SpeakEasy.net DSL

The Modular Manual Browser

Home Page
Manual: (SunOS-4.1.3)
Apropos / Subsearch:
optional field

UNLINK(2V)                                                          UNLINK(2V)

       unlink - remove directory entry

       int unlink(path)
       char *path;

       unlink()  removes  the directory entry named by the pathname pointed to
       by path and decrements the link count of the file referred to  by  that
       entry.  If this entry was the last link to the file, and no process has
       the file  open,  then  all  resources  associated  with  the  file  are
       reclaimed.   If,  however, the file was open in any process, the actual
       resource reclamation is delayed until it is  closed,  even  though  the
       directory entry has disappeared.

       If  path  refers  to  a directory, the effective user-ID of the calling
       process must be super-user.

       Upon successful completion, unlink() marks for update the st_ctime  and
       st_mtime  fields  of  the  parent  directory.  Also, if the file's link
       count is not zero, the st_ctime field of the file is marked for update.

       unlink() returns:

       0      on success.

       -1     on failure and sets errno to indicate the error.

       EACCES              Search permission is denied for a component of  the
                           path prefix of path.

                           Write  permission  is denied for the directory con-
                           taining the link to be removed.

       EBUSY               The entry to be unlinked is the mount point  for  a
                           mounted file system.

       EFAULT              path points outside the process's allocated address

       EINVAL              The file referred to by path is the current  direc-
                           tory, `.'.

       EIO                 An I/O error occurred while reading from or writing
                           to the file system.

       ELOOP               Too many symbolic links were encountered in  trans-
                           lating path.

       ENAMETOOLONG        The length of the path argument exceeds {PATH_MAX}.

                           A  pathname  component  is  longer  than {NAME_MAX}
                           while {_POSIX_NO_TRUNC} is  in  effect  (see  path-

       ENOENT              The file referred to by path does not exist.

       ENOTDIR             A  component  of  the  path prefix of path is not a

       EPERM               The file referred to by path is a directory and the
                           effective  user ID of the process is not the super-

       EROFS               The file referred to by path resides on a read-only
                           file system.

       In addition to the above, the following may also occur:

       ENOENT              path points to an empty string.

       close(2V), link(2V), rmdir(2V)

       Applications should use rmdir(2V) to remove directories.  Although root
       may use unlink() on directories, all users may use rmdir().

                                21 January 1990                     UNLINK(2V)