UNLINK(2-POSIX) RISC/os Reference Manual UNLINK(2-POSIX)
NAME
unlink - remove directory entry
SYNOPSIS
int unlink (path)
char *path;
DESCRIPTION
unlink removes the directory entry named by the path name
pointed to by path.
path must not specify a directory unless the process' effec-
tive user ID is the superuser. Applications should use
rmdir to remove a directory.
When all links to a file have been removed and no process
has the file open, the space occupied by the file is freed
and the file ceases to exist. If one or more processes have
the file open when the last link is removed, the removal is
postponed until all references to the file have been closed.
Upon successful completion, the unlink function marks for
update the st_ctime and st_mtime fields of the parent direc-
tory. Also, if the file's link count is not zero, the
st_ctime field of the file is marked for update.
RETURN VALUES
Upon successful completion, a value of 0 is returned. Oth-
erwise, a value of -1 is returned and errno is set to indi-
cate the error.
ERRORS
The named file is not unlinked if one or more of the follow-
ing are true:
[ENOTDIR] A component of the path prefix is not a
directory.
[ENOENT] The named file does not exist.
[EACCES] Search permission is denied for a com-
ponent of the path prefix, or write per-
mission is denied on the directory con-
taining the link to be removed.
[EPERM] The named file is a directory and the
effective user ID of the process is not
super-user.
[EBUSY] The entry to be unlinked is the mount
point for a mounted file system.
Printed 1/15/91 Page 1
UNLINK(2-POSIX) RISC/os Reference Manual UNLINK(2-POSIX)
[ETXTBSY] The entry to be unlinked is the last
link to a pure procedure (shared text)
file that is being executed.
[EROFS] The directory entry to be unlinked is
part of a read-only file system.
[EFAULT] path points outside the process's allo-
cated address space.
[EINTR] A signal was caught during the unlink
system call.
[ENAMETOOLONG] The length of path exceeds {PATH_MAX},
or a pathname component is longer than
{NAME_MAX} while {_POSIX_NO_TRUNC} is in
effect.
SEE ALSO
close(2), link(2), open(2), rename(2), rmdir(2).
rm(1) in the User's Reference Manual.
Page 2 Printed 1/15/91