1UNLINK(2)                     System Calls Manual                    UNLINK(2)
2
3
4

NAME

6       unlink - remove directory entry
7

SYNOPSIS

9       unlink(path)
10       char *path;
11

DESCRIPTION

13       Unlink removes the entry for the file path from its directory.  If this
14       entry was the last link to the file, and no process has the file  open,
15       then  all  resources  associated with the file are reclaimed.  If, how‐
16       ever, the file was open in any process, the actual resource reclamation
17       is delayed until it is closed, even though the directory entry has dis‐
18       appeared.
19

RETURN VALUE

21       Upon successful completion, a value of 0  is  returned.   Otherwise,  a
22       value of -1 is returned and errno is set to indicate the error.
23

ERRORS

25       The unlink succeeds unless:
26
27       [ENOTDIR]      A component of the path prefix is not a directory.
28
29       [EINVAL]       The  pathname  contains  a character with the high-order
30                      bit set.
31
32       [ENAMETOOLONG] A component of a pathname exceeded 255 characters, or an
33                      entire path name exceeded 1023 characters.
34
35       [ENOENT]       The named file does not exist.
36
37       [EACCES]       Search  permission is denied for a component of the path
38                      prefix.
39
40       [EACCES]       Write permission is denied on the  directory  containing
41                      the link to be removed.
42
43       [ELOOP]        Too  many symbolic links were encountered in translating
44                      the pathname.
45
46       [EPERM]        The named file is a directory and the effective user  ID
47                      of the process is not the super-user.
48
49       [EPERM]        The  directory containing the file is marked sticky, and
50                      neither the containing directory  nor  the  file  to  be
51                      removed are owned by the effective user ID.
52
53       [EBUSY]        The  entry  to  be  unlinked  is  the  mount point for a
54                      mounted file system.
55
56       [EIO]          An I/O error occurred while deleting the directory entry
57                      or deallocating the inode.
58
59       [EROFS]        The named file resides on a read-only file system.
60
61       [EFAULT]       Path  points  outside  the  process's  allocated address
62                      space.
63

SEE ALSO

65       close(2), link(2), rmdir(2)
66
67
68
694th Berkeley Distribution        May 22, 1985                        UNLINK(2)
Impressum