1 .\" Copyright (c) 1980 Regents of the University of California.
2 .\" All rights reserved. The Berkeley software License Agreement
3 .\" specifies the terms and conditions for redistribution.
5 .\" @(#)unlink.2 6.2 (Berkeley) 5/22/85
7 .TH UNLINK 2 "May 22, 1985"
10 unlink \- remove directory entry
16 int unlink(const char *path)
21 removes the entry for the file
24 If this entry was the last link to the file,
25 and no process has the file open, then
26 all resources associated with the file are reclaimed.
27 If, however, the file was open in any process, the actual
28 resource reclamation is delayed until it is closed,
29 even though the directory entry has disappeared.
31 Upon successful completion, a value of 0 is returned.
32 Otherwise, a value of \-1 is returned and
34 is set to indicate the error.
36 The \fIunlink\fP succeeds unless:
39 A component of the path prefix is not a directory.
42 The path name exceeds PATH_MAX characters.
45 The named file does not exist.
48 Search permission is denied for a component of the path prefix.
51 Write permission is denied on the directory containing the link
55 Too many symbolic links were encountered in translating the pathname.
59 The named file is a directory.
62 The directory containing the file is marked sticky,
63 and neither the containing directory nor the file to be removed
64 are owned by the effective user ID.
68 The entry to be unlinked is the mount point for a
72 An I/O error occurred while deleting the directory entry
73 or deallocating the inode.
76 The named file resides on a read-only file system.
80 points outside the process's allocated address space.