]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man2/unlink.2
Fix redundant formatting macros
[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.
c13182ef 14.\"
fea681da
MK
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.
c13182ef 22.\"
fea681da
MK
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
c11b1abf 30.\" Modified 2004-06-23 by Michael Kerrisk <mtk.manpages@gmail.com>
fea681da 31.\"
d9343c5c 32.TH UNLINK 2 2004-06-23 "Linux" "Linux Programmer's Manual"
fea681da
MK
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 ()
c13182ef
MK
41deletes a name from the filesystem.
42If that name was the
fea681da
MK
43last link to a file and no processes have the file open the file is
44deleted and the space it was using is made available for reuse.
45
46If the name was the last link to a file but any processes still have
47the file open the file will remain in existence until the last file
48descriptor referring to it is closed.
49
50If the name referred to a symbolic link the link is removed.
51
52If the name referred to a socket, fifo or device the name for it is
53removed but processes which have the object open may continue to use
54it.
55.SH "RETURN VALUE"
1c44bd5b
MK
56On success, zero is returned.
57On error, \-1 is returned, and
fea681da
MK
58.I errno
59is set appropriately.
60.SH ERRORS
61.TP
62.B EACCES
63Write access to the directory containing
64.I pathname
65is not allowed for the process's effective UID, or one of the
66directories in
0daa9e92 67.I pathname
fea681da
MK
68did not allow search permission.
69(See also
ad7cc990 70.BR path_resolution (7).)
fea681da
MK
71.TP
72.BR EBUSY " (not on Linux)"
73The file
74.I pathname
75cannot be unlinked because it is being used by the system
76or another process and the implementation considers this an error.
77.TP
78.B EFAULT
79.I pathname
80points outside your accessible address space.
81.TP
82.B EIO
83An I/O error occurred.
84.TP
85.B EISDIR
86.I pathname
87refers to a directory.
88(This is the non-POSIX value returned by Linux since 2.1.132.)
89.TP
90.B ELOOP
91Too many symbolic links were encountered in translating
92.IR pathname .
93.TP
94.B ENAMETOOLONG
95.IR pathname " was too long."
96.TP
97.B ENOENT
98A component in
99.I pathname
100does not exist or is a dangling symbolic link, or
101.I pathname
102is empty.
103.TP
104.B ENOMEM
105Insufficient kernel memory was available.
106.TP
107.B ENOTDIR
108A component used as a directory in
109.I pathname
110is not, in fact, a directory.
111.TP
112.B EPERM
113The system does not allow unlinking of directories,
114or unlinking of directories requires privileges that the
115current process doesn't have.
7bbd888b
MK
116(This is the POSIX prescribed error return;
117as noted above, Linux returns
118.B EISDIR
119for this case.)
fea681da
MK
120.TP
121.BR EPERM " (Linux only)"
122The filesystem does not allow unlinking of files.
123.TP
124.BR EPERM " or " EACCES
125The directory containing
126.I pathname
127has the sticky bit
128.RB ( S_ISVTX )
129set and the process's effective UID is neither the UID of the file to
130be deleted nor that of the directory containing it, and
131the process is not privileged (Linux: does not have the
132.B CAP_FOWNER
133capability).
134.TP
135.B EROFS
136.I pathname
137refers to a file on a read-only filesystem.
138.SH "CONFORMING TO"
c13182ef 139SVr4, 4.3BSD, POSIX.1-2001.
97c1eac8
MK
140.\" SVr4 documents additional error
141.\" conditions EINTR, EMULTIHOP, ETXTBSY, ENOLINK.
fea681da
MK
142.SH BUGS
143Infelicities in the protocol underlying NFS can cause the unexpected
144disappearance of files which are still being used.
145.SH "SEE ALSO"
146.BR rm (1),
147.BR chmod (2),
148.BR link (2),
149.BR mknod (2),
150.BR open (2),
fea681da
MK
151.BR rename (2),
152.BR rmdir (2),
f5958902 153.BR unlinkat (2),
fea681da 154.BR mkfifo (3),
ad7cc990
MK
155.BR remove (3),
156.BR path_resolution (7)