Commit | Line | Data |
---|---|---|
3e847271 KM |
1 | .\" Copyright (c) 1980 Regents of the University of California. |
2 | .\" All rights reserved. The Berkeley software License Agreement | |
3 | .\" specifies the terms and conditions for redistribution. | |
4 | .\" | |
b5984ffe | 5 | .\" @(#)unlink.2 6.2 (Berkeley) %G% |
3e847271 | 6 | .\" |
3be4d10a | 7 | .TH UNLINK 2 "" |
3e847271 KM |
8 | .UC 4 |
9 | .SH NAME | |
10 | unlink \- remove directory entry | |
11 | .SH SYNOPSIS | |
12 | .nf | |
4c6f63c8 KM |
13 | .ft B |
14 | unlink(path) | |
15 | char *path; | |
3e847271 | 16 | .fi |
4c6f63c8 | 17 | .ft R |
3e847271 | 18 | .SH DESCRIPTION |
3e847271 | 19 | .I Unlink |
4c6f63c8 KM |
20 | removes the entry for the file |
21 | .I path | |
3e847271 KM |
22 | from its directory. |
23 | If this entry was the last link to the file, | |
4c6f63c8 KM |
24 | and no process has the file open, then |
25 | all resources associated with the file are reclaimed. | |
3e847271 | 26 | If, however, the file was open in any process, the actual |
4c6f63c8 KM |
27 | resource reclamation is delayed until it is closed, |
28 | even though the directory entry has disappeared. | |
29 | .SH "RETURN VALUE | |
30 | Upon successful completion, a value of 0 is returned. | |
31 | Otherwise, a value of \-1 is returned and | |
32 | .I errno | |
33 | is set to indicate the error. | |
34 | .SH "ERRORS | |
35 | The \fIunlink\fP succeeds unless: | |
36 | .TP 15 | |
4c6f63c8 KM |
37 | [ENOTDIR] |
38 | A component of the path prefix is not a directory. | |
39 | .TP 15 | |
b5984ffe KM |
40 | [EINVAL] |
41 | The pathname contains a character with the high-order bit set. | |
42 | .TP 15 | |
43 | [ENAMETOOLONG] | |
44 | A component of a pathname exceeded 255 characters, | |
45 | or an entire path name exceeded 1023 characters. | |
46 | .TP 15 | |
4c6f63c8 KM |
47 | [ENOENT] |
48 | The named file does not exist. | |
49 | .TP 15 | |
50 | [EACCES] | |
51 | Search permission is denied for a component of the path prefix. | |
52 | .TP 15 | |
53 | [EACCES] | |
54 | Write permission is denied on the directory containing the link | |
55 | to be removed. | |
56 | .TP 15 | |
b5984ffe KM |
57 | [ELOOP] |
58 | Too many symbolic links were encountered in translating the pathname. | |
59 | .TP 15 | |
4c6f63c8 KM |
60 | [EPERM] |
61 | The named file is a directory and the effective user ID | |
62 | of the process is not the super-user. | |
63 | .TP 15 | |
b5984ffe KM |
64 | [EPERM] |
65 | The directory containing the file is marked sticky, | |
66 | and neither the containing directory nor the file to be removed | |
67 | are owned by the effective user ID. | |
68 | .TP 15 | |
4c6f63c8 KM |
69 | [EBUSY] |
70 | The entry to be unlinked is the mount point for a | |
71 | mounted file system. | |
72 | .TP 15 | |
b5984ffe KM |
73 | [EIO] |
74 | An I/O error occurred while deleting the directory entry | |
75 | or deallocating the inode. | |
76 | .TP 15 | |
4c6f63c8 KM |
77 | [EROFS] |
78 | The named file resides on a read-only file system. | |
79 | .TP 15 | |
80 | [EFAULT] | |
81 | .I Path | |
82 | points outside the process's allocated address space. | |
3e847271 | 83 | .SH "SEE ALSO" |
4c6f63c8 | 84 | close(2), link(2), rmdir(2) |