UNLINK(2,L) AIX Technical Reference UNLINK(2,L)
-------------------------------------------------------------------------------
unlink, rmslink, remove
PURPOSE
Removes a directory entry.
SYNTAX
int unlink (path) int remove (path)
char *path; char *path;
int rmslink (path)
char *path;
DESCRIPTION
The unlink system call removes the directory entry specified by the path
parameter. The remove subroutine is identical to unlink. It is provided for
ANSI-C compatability.
If the named file is a symbolic link to another file or directory, unlink
removes the symbolic link, not the file or directory to which it refers.
When all links to a file are 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 are closed.
If path exists, and the parent directory of path has the sticky attribute bit
set, the calling process must have an effective user ID equal to:
o the owner ID of path, or to
o the owner ID of the parent directory of path.
If the Transparent Computing Facility is installed, the following is
applicable.
The system call unlink fails on symbolic links in system type replicated file
systems. To remove the links, the rmslink system call must be used. This
system call functions the same as unlink otherwise.
When a file which has been replicated is unlinked, the change is reflected in
all other copies of the file system at the earliest possible moment. Copies of
the file system which were not mounted when the unlink occurred, or mounted on
Processed November 7, 1990 UNLINK(2,L) 1
UNLINK(2,L) AIX Technical Reference UNLINK(2,L)
a site not in communication with the primary site for the file system, do not
see the effect of the unlink until that copy is mounted in a cluster that
includes a copy of the file system which has seen the change.
RETURN VALUE
Upon successful completion, a value of 0 is returned. If the unlink system
call fails, a value of -1 is returned and errno is set to indicate the error.
ERROR CONDITIONS
The unlink system call fails and the named file is not unlinked if one or more
of the following 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 component of the path prefix.
EACCES Write permission is denied on the directory containing the link to be
removed.
EPERM The named file is a directory and the effective user ID of the process
is not superuser.
EPERM The file named by the path parameter is in a directory with the sticky
attribute bit set, and the effective user ID of the calling process is
not equal to the owner of the file or of the parent directory.
EBUSY The entry to be unlinked is the mount point for a mounted file system.
ETXTBSY The entry to be unlinked is the last link to a pure procedure (shared
text) file that is being executed.
EROFS The entry to be unlinked is part of a read-only file system.
EFAULT The path parameter points to a location outside of the process's
allocated address space.
ESTALE The process's root or current directory is located in a virtual file
system that has been unmounted.
ENAMETOOLONG
A component of the path parameter exceeded NAME_MAX characters or the
entire path parameter exceeded PATH_MAX characters.
EISDIR A hidden directory was named, components within hidden directories must
be explicitly named.
Processed November 7, 1990 UNLINK(2,L) 2
UNLINK(2,L) AIX Technical Reference UNLINK(2,L)
ENOENT A symbolic link was named in the path prefix, but the file to which it
refers does not exist. Since unlink and rmslink do not follow symbolic
links on the last component of a path, this error cannot occur on the
last component.
ELOOP A loop of symbolic links was detected. Since unlink and rmslink do not
follow symbolic links on the last component of a path, this error
cannot occur on the last component.
ENFILE The system inode table is full.
If the Transparent Computing Facility is installed on your system, unlink can
also fail if one or more of the following are true:
ESITEDN1 path cannot be accessed because a site went down.
ESITEDN2 The operation was terminated because a site failed.
ENOSTORE path is a name relative to the working directory, but no site which
stores this directory is currently up.
ENOSTORE A component of path is replicated but not stored on any site which is
currently up.
EROFS The directory entry to be unlinked is part of a replicated file
system whose primary copy is currently unavailable.
EINTR A signal was caught during the system call.
RELATED INFORMATION
In this book: "close, closex," "link," and "open, openx, creat."
The rm command in AIX Operating System Commands Reference.
Processed November 7, 1990 UNLINK(2,L) 3