add note about finding the end of memory
[unix-history] / usr / src / lib / libc / sys / unlink.2
CommitLineData
3e847271
KM
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.
4.\"
b5984ffe 5.\" @(#)unlink.2 6.2 (Berkeley) %G%
3e847271 6.\"
3be4d10a 7.TH UNLINK 2 ""
3e847271
KM
8.UC 4
9.SH NAME
10unlink \- remove directory entry
11.SH SYNOPSIS
12.nf
4c6f63c8
KM
13.ft B
14unlink(path)
15char *path;
3e847271 16.fi
4c6f63c8 17.ft R
3e847271 18.SH DESCRIPTION
3e847271 19.I Unlink
4c6f63c8
KM
20removes the entry for the file
21.I path
3e847271
KM
22from its directory.
23If this entry was the last link to the file,
4c6f63c8
KM
24and no process has the file open, then
25all resources associated with the file are reclaimed.
3e847271 26If, however, the file was open in any process, the actual
4c6f63c8
KM
27resource reclamation is delayed until it is closed,
28even though the directory entry has disappeared.
29.SH "RETURN VALUE
30Upon successful completion, a value of 0 is returned.
31Otherwise, a value of \-1 is returned and
32.I errno
33is set to indicate the error.
34.SH "ERRORS
35The \fIunlink\fP succeeds unless:
36.TP 15
4c6f63c8
KM
37[ENOTDIR]
38A component of the path prefix is not a directory.
39.TP 15
b5984ffe
KM
40[EINVAL]
41The pathname contains a character with the high-order bit set.
42.TP 15
43[ENAMETOOLONG]
44A component of a pathname exceeded 255 characters,
45or an entire path name exceeded 1023 characters.
46.TP 15
4c6f63c8
KM
47[ENOENT]
48The named file does not exist.
49.TP 15
50[EACCES]
51Search permission is denied for a component of the path prefix.
52.TP 15
53[EACCES]
54Write permission is denied on the directory containing the link
55to be removed.
56.TP 15
b5984ffe
KM
57[ELOOP]
58Too many symbolic links were encountered in translating the pathname.
59.TP 15
4c6f63c8
KM
60[EPERM]
61The named file is a directory and the effective user ID
62of the process is not the super-user.
63.TP 15
b5984ffe
KM
64[EPERM]
65The directory containing the file is marked sticky,
66and neither the containing directory nor the file to be removed
67are owned by the effective user ID.
68.TP 15
4c6f63c8
KM
69[EBUSY]
70The entry to be unlinked is the mount point for a
71mounted file system.
72.TP 15
b5984ffe
KM
73[EIO]
74An I/O error occurred while deleting the directory entry
75or deallocating the inode.
76.TP 15
4c6f63c8
KM
77[EROFS]
78The named file resides on a read-only file system.
79.TP 15
80[EFAULT]
81.I Path
82points outside the process's allocated address space.
3e847271 83.SH "SEE ALSO"
4c6f63c8 84close(2), link(2), rmdir(2)