]> CyberLeo.Net >> Repos - FreeBSD/releng/7.2.git/blob - lib/libc/sys/unlink.2
Create releng/7.2 from stable/7 in preparation for 7.2-RELEASE.
[FreeBSD/releng/7.2.git] / lib / libc / sys / unlink.2
1 .\" Copyright (c) 1980, 1991, 1993
2 .\"     The Regents of the University of California.  All rights reserved.
3 .\"
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
6 .\" are met:
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\"    notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\"    notice, this list of conditions and the following disclaimer in the
11 .\"    documentation and/or other materials provided with the distribution.
12 .\" 4. Neither the name of the University nor the names of its contributors
13 .\"    may be used to endorse or promote products derived from this software
14 .\"    without specific prior written permission.
15 .\"
16 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
17 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
20 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 .\" SUCH DAMAGE.
27 .\"
28 .\"     @(#)unlink.2    8.1 (Berkeley) 6/4/93
29 .\" $FreeBSD$
30 .\"
31 .Dd December 10, 2006
32 .Dt UNLINK 2
33 .Os
34 .Sh NAME
35 .Nm unlink
36 .Nd remove directory entry
37 .Sh LIBRARY
38 .Lb libc
39 .Sh SYNOPSIS
40 .In unistd.h
41 .Ft int
42 .Fn unlink "const char *path"
43 .Sh DESCRIPTION
44 The
45 .Fn unlink
46 system call
47 removes the link named by
48 .Fa path
49 from its directory and decrements the link count of the
50 file which was referenced by the link.
51 If that decrement reduces the link count of the file
52 to zero,
53 and no process has the file open, then
54 all resources associated with the file are reclaimed.
55 If one or more process have the file open when the last link is removed,
56 the link is removed, but the removal of the file is delayed until
57 all references to it have been closed.
58 The
59 .Fa path
60 argument
61 may not be a directory.
62 .Sh RETURN VALUES
63 .Rv -std unlink
64 .Sh ERRORS
65 The
66 .Fn unlink
67 succeeds unless:
68 .Bl -tag -width Er
69 .It Bq Er ENOTDIR
70 A component of the path prefix is not a directory.
71 .It Bq Er ENAMETOOLONG
72 A component of a pathname exceeded 255 characters,
73 or an entire path name exceeded 1023 characters.
74 .It Bq Er ENOENT
75 The named file does not exist.
76 .It Bq Er EACCES
77 Search permission is denied for a component of the path prefix.
78 .It Bq Er EACCES
79 Write permission is denied on the directory containing the link
80 to be removed.
81 .It Bq Er ELOOP
82 Too many symbolic links were encountered in translating the pathname.
83 .It Bq Er EPERM
84 The named file is a directory.
85 .It Bq Er EPERM
86 The named file has its immutable, undeletable or append-only flag set, see the
87 .Xr chflags 2
88 manual page for more information.
89 .It Bq Er EPERM
90 The parent directory of the named file has its immutable or append-only flag
91 set.
92 .It Bq Er EPERM
93 The directory containing the file is marked sticky,
94 and neither the containing directory nor the file to be removed
95 are owned by the effective user ID.
96 .It Bq Er EIO
97 An I/O error occurred while deleting the directory entry
98 or deallocating the inode.
99 .It Bq Er EROFS
100 The named file resides on a read-only file system.
101 .It Bq Er EFAULT
102 The
103 .Fa path
104 argument
105 points outside the process's allocated address space.
106 .El
107 .Sh SEE ALSO
108 .Xr chflags 2 ,
109 .Xr close 2 ,
110 .Xr link 2 ,
111 .Xr rmdir 2 ,
112 .Xr symlink 7
113 .Sh HISTORY
114 The
115 .Fn unlink
116 function appeared in
117 .At v6 .
118 .Pp
119 The
120 .Fn unlink
121 system call traditionally allows the super-user to unlink directories which
122 can damage the file system integrity.
123 This implementation no longer permits
124 it.