SCCS id got lost along the way
[unix-history] / usr / src / lib / libc / sys / unlink.2
CommitLineData
931b8415
CL
1.\" Copyright (c) 1980, 1991 Regents of the University of California.
2.\" All rights reserved.
3e847271 3.\"
931b8415 4.\" %sccs.include.redist.man%
3e847271 5.\"
931b8415
CL
6.\" @(#)unlink.2 6.3 (Berkeley) %G%
7.\"
8.Dd
9.Dt UNLINK 2
10.Os BSD 4
11.Sh NAME
12.Nm unlink
13.Nd remove directory entry
14.Sh SYNOPSIS
15.Fd #include <unistd.h>
16.Ft int
17.Fn unlink "const char *path"
18.Sh DESCRIPTION
19The
20.Fn unlink
21function
22removes the link named by
23.Fa path
24from its directory and decrements the link count of the
25file which was referenced by the link.
26If that decrement reduces the link count of the file
27to zero,
4c6f63c8
KM
28and no process has the file open, then
29all resources associated with the file are reclaimed.
931b8415
CL
30If one or more process have the file open when the last link is removed,
31the link is removed, but the removal of the file is delayed until
32all references to it have been closed.
33.Sh RETURN VALUES
4c6f63c8 34Upon successful completion, a value of 0 is returned.
931b8415
CL
35Otherwise, a value of -1 is returned and
36.Va errno
4c6f63c8 37is set to indicate the error.
931b8415
CL
38.Sh ERRORS
39The
40.Fn unlink
41succeeds unless:
42.Bl -tag -width ENAMETOOLONGAA
43.It Bq Er ENOTDIR
4c6f63c8 44A component of the path prefix is not a directory.
931b8415 45.It Bq Er EINVAL
b5984ffe 46The pathname contains a character with the high-order bit set.
931b8415 47.It Bq Er ENAMETOOLONG
b5984ffe
KM
48A component of a pathname exceeded 255 characters,
49or an entire path name exceeded 1023 characters.
931b8415 50.It Bq Er ENOENT
4c6f63c8 51The named file does not exist.
931b8415 52.It Bq Er EACCES
4c6f63c8 53Search permission is denied for a component of the path prefix.
931b8415 54.It Bq Er EACCES
4c6f63c8
KM
55Write permission is denied on the directory containing the link
56to be removed.
931b8415 57.It Bq Er ELOOP
b5984ffe 58Too many symbolic links were encountered in translating the pathname.
931b8415 59.It Bq Er EPERM
4c6f63c8
KM
60The named file is a directory and the effective user ID
61of the process is not the super-user.
931b8415 62.It Bq Er EPERM
b5984ffe
KM
63The directory containing the file is marked sticky,
64and neither the containing directory nor the file to be removed
65are owned by the effective user ID.
931b8415 66.It Bq Er EBUSY
4c6f63c8
KM
67The entry to be unlinked is the mount point for a
68mounted file system.
931b8415 69.It Bq Er EIO
b5984ffe
KM
70An I/O error occurred while deleting the directory entry
71or deallocating the inode.
931b8415 72.It Bq Er EROFS
4c6f63c8 73The named file resides on a read-only file system.
931b8415
CL
74.It Bq Er EFAULT
75.Fa Path
4c6f63c8 76points outside the process's allocated address space.
931b8415
CL
77.El
78.Sh SEE ALSO
79.Xr close 2 ,
80.Xr link 2 ,
81.Xr rmdir 2
82.Sh HISTORY
83An
84.Nm
85function call appeared in Version 6 AT&T UNIX.