| 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 | .\" |
| 5 | .\" @(#)unlink.2 6.2 (Berkeley) %G% |
| 6 | .\" |
| 7 | .TH UNLINK 2 "" |
| 8 | .UC 4 |
| 9 | .SH NAME |
| 10 | unlink \- remove directory entry |
| 11 | .SH SYNOPSIS |
| 12 | .nf |
| 13 | .ft B |
| 14 | unlink(path) |
| 15 | char *path; |
| 16 | .fi |
| 17 | .ft R |
| 18 | .SH DESCRIPTION |
| 19 | .I Unlink |
| 20 | removes the entry for the file |
| 21 | .I path |
| 22 | from its directory. |
| 23 | If this entry was the last link to the file, |
| 24 | and no process has the file open, then |
| 25 | all resources associated with the file are reclaimed. |
| 26 | If, however, the file was open in any process, the actual |
| 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 |
| 37 | [ENOTDIR] |
| 38 | A component of the path prefix is not a directory. |
| 39 | .TP 15 |
| 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 |
| 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 |
| 57 | [ELOOP] |
| 58 | Too many symbolic links were encountered in translating the pathname. |
| 59 | .TP 15 |
| 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 |
| 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 |
| 69 | [EBUSY] |
| 70 | The entry to be unlinked is the mount point for a |
| 71 | mounted file system. |
| 72 | .TP 15 |
| 73 | [EIO] |
| 74 | An I/O error occurred while deleting the directory entry |
| 75 | or deallocating the inode. |
| 76 | .TP 15 |
| 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. |
| 83 | .SH "SEE ALSO" |
| 84 | close(2), link(2), rmdir(2) |