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