]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man2/unlink.2
Updated CONFORMING TO section
[thirdparty/man-pages.git] / man2 / unlink.2
CommitLineData
fea681da
MK
1.\" Hey Emacs! This file is -*- nroff -*- source.
2.\"
3.\" This manpage is Copyright (C) 1992 Drew Eckhardt;
4.\" 1993 Ian Jackson.
5.\"
6.\" Permission is granted to make and distribute verbatim copies of this
7.\" manual provided the copyright notice and this permission notice are
8.\" preserved on all copies.
9.\"
10.\" Permission is granted to copy and distribute modified versions of this
11.\" manual under the conditions for verbatim copying, provided that the
12.\" entire resulting derived work is distributed under the terms of a
13.\" permission notice identical to this one.
14.\"
15.\" Since the Linux kernel and libraries are constantly changing, this
16.\" manual page may be incorrect or out-of-date. The author(s) assume no
17.\" responsibility for errors or omissions, or for damages resulting from
18.\" the use of the information contained herein. The author(s) may not
19.\" have taken the same level of care in the production of this manual,
20.\" which is licensed free of charge, as they might when working
21.\" professionally.
22.\"
23.\" Formatted or processed versions of this manual, if unaccompanied by
24.\" the source, must acknowledge the copyright and authors of this work.
25.\"
26.\" Modified 1993-07-24 by Rik Faith <faith@cs.unc.edu>
27.\" Modified 1996-09-08 by Arnt Gulbrandsen <agulbra@troll.no>
28.\" Modified 1997-01-31 by Eric S. Raymond <esr@thyrsus.com>
29.\" Modified 2001-05-17 by aeb
305a0578 30.\" Modified 2004-06-23 by Michael Kerrisk <mtk-manpages@gmx.net>
fea681da
MK
31.\"
32.TH UNLINK 2 2004-06-23 "Linux 2.6.7" "Linux Programmer's Manual"
33.SH NAME
34unlink \- delete a name and possibly the file it refers to
35.SH SYNOPSIS
36.B #include <unistd.h>
37.sp
38.BI "int unlink(const char *" pathname );
39.SH DESCRIPTION
e511ffb6 40.BR unlink ()
fea681da
MK
41deletes a name from the filesystem. If that name was the
42last link to a file and no processes have the file open the file is
43deleted and the space it was using is made available for reuse.
44
45If the name was the last link to a file but any processes still have
46the file open the file will remain in existence until the last file
47descriptor referring to it is closed.
48
49If the name referred to a symbolic link the link is removed.
50
51If the name referred to a socket, fifo or device the name for it is
52removed but processes which have the object open may continue to use
53it.
54.SH "RETURN VALUE"
55On success, zero is returned. On error, \-1 is returned, and
56.I errno
57is set appropriately.
58.SH ERRORS
59.TP
60.B EACCES
61Write access to the directory containing
62.I pathname
63is not allowed for the process's effective UID, or one of the
64directories in
65.IR pathname
66did not allow search permission.
67(See also
68.BR path_resolution (2).)
69.TP
70.BR EBUSY " (not on Linux)"
71The file
72.I pathname
73cannot be unlinked because it is being used by the system
74or another process and the implementation considers this an error.
75.TP
76.B EFAULT
77.I pathname
78points outside your accessible address space.
79.TP
80.B EIO
81An I/O error occurred.
82.TP
83.B EISDIR
84.I pathname
85refers to a directory.
86(This is the non-POSIX value returned by Linux since 2.1.132.)
87.TP
88.B ELOOP
89Too many symbolic links were encountered in translating
90.IR pathname .
91.TP
92.B ENAMETOOLONG
93.IR pathname " was too long."
94.TP
95.B ENOENT
96A component in
97.I pathname
98does not exist or is a dangling symbolic link, or
99.I pathname
100is empty.
101.TP
102.B ENOMEM
103Insufficient kernel memory was available.
104.TP
105.B ENOTDIR
106A component used as a directory in
107.I pathname
108is not, in fact, a directory.
109.TP
110.B EPERM
111The system does not allow unlinking of directories,
112or unlinking of directories requires privileges that the
113current process doesn't have.
7bbd888b
MK
114(This is the POSIX prescribed error return;
115as noted above, Linux returns
116.B EISDIR
117for this case.)
fea681da
MK
118.TP
119.BR EPERM " (Linux only)"
120The filesystem does not allow unlinking of files.
121.TP
122.BR EPERM " or " EACCES
123The directory containing
124.I pathname
125has the sticky bit
126.RB ( S_ISVTX )
127set and the process's effective UID is neither the UID of the file to
128be deleted nor that of the directory containing it, and
129the process is not privileged (Linux: does not have the
130.B CAP_FOWNER
131capability).
132.TP
133.B EROFS
134.I pathname
135refers to a file on a read-only filesystem.
136.SH "CONFORMING TO"
137SVr4, SVID, POSIX, X/OPEN, 4.3BSD. SVr4 documents additional error
138conditions EINTR, EMULTIHOP, ETXTBSY, ENOLINK.
139.SH BUGS
140Infelicities in the protocol underlying NFS can cause the unexpected
141disappearance of files which are still being used.
142.SH "SEE ALSO"
143.BR rm (1),
144.BR chmod (2),
145.BR link (2),
146.BR mknod (2),
147.BR open (2),
148.BR path_resolution (2),
149.BR rename (2),
150.BR rmdir (2),
f5958902 151.BR unlinkat (2),
fea681da
MK
152.BR mkfifo (3),
153.BR remove (3)