OSDN Git Service

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