UNLINK
Section: System Calls (2)
Updated: August 1, 1992
Index
Return to Main Contents
NAME
unlink - remove directory entry
SYNOPSIS
int unlink(const char *path);
DESCRIPTION
The
unlink
function removes the link whose pathname is specified by path
and decrement the link count of the file referenced by the link.
If this entry was the last link to the file,
and no process has the file open, then
all resources associated with the file are reclaimed.
If, however, the file was open in any process, the actual
resource reclamation is delayed until it is closed,
even though the directory entry has disappeared.
The path argument must not name a directory.
Applications should use
rmdir
to remove a directory.
Upon successful completion, the
unlink
function marks for update the st_ctime and st_mtime fields of
the parent directory of the entry to be removed.
Furthermore, if the link count of the file is not zero, then the
st_ctime field of the file is also marked for update.
RETURN VALUE
Upon successful completion, a value of zero is returned.
Otherwise, a value of -1 is returned and errno
is set to indicate the error.
ERRORS
If any of the following conditions occurs, the
unlink
function returns -1 and sets errno to the corresponding value:
- [EACCES]
-
Search permission is denied for a component of the path prefix.
- [EACCES]
-
Write permission is denied on the directory containing the link
to be removed.
- [EBUSY]
-
The entry to be unlinked is the mount point for a
mounted file system.
- [EFAULT]
-
The path argument points outside the process's allocated address space.
- [EINVAL]
-
The pathname contains a character with the high-order bit set.
- [EIO]
-
An I/O error occurred while deleting the directory entry
or deallocating the inode.
- [ELOOP]
-
Too many symbolic links were encountered in translating the pathname.
- [ENAMETOOLONG]
-
A component of
path
exceeds 255 characters,
or the entire pathname exceeds 1023 characters.
For POSIX applications these values are given
by the constants {NAME_MAX} and {PATH_MAX}, respectively.
- [ENOENT]
-
The named file does not exist.
- [ENOENT]
-
The path argument points to an empty string.
- [ENOTDIR]
-
A component of the path prefix is not a directory.
- [EPERM]
-
The named file is a directory.
- [EPERM]
-
The directory containing the file is marked sticky,
and neither the containing directory nor the file to be removed
are owned by the effective user ID.
- [EROFS]
-
The named file resides on a read-only file system.
SEE ALSO
close(2),
link(2),
open(2),
rename(2),
rmdir(2)
Index
- NAME
-
- SYNOPSIS
-
- DESCRIPTION
-
- RETURN VALUE
-
- ERRORS
-
- SEE ALSO
-
This document was created by
man2html,
using the manual pages.
Time: 00:59:12 GMT, September 26, 2024