LINK(2,L) AIX Technical Reference LINK(2,L)
-------------------------------------------------------------------------------
link
PURPOSE
Creates an additional directory entry for an existing file.
LIBRARY
Standard C Library (libc.a)
SYNTAX
int link (path1, path2)
char *path1, *path2;
DESCRIPTION
The link system call creates an additional link (directory entry) for an
existing file. The path1 parameter points to the path name of an existing file
and provides the inumber to be used. The path2 parameter points to the path
name for the new directory entry to be created.
If the path1 parameter is a symbolic link, it is followed and the link is made
to the file pointed at by the symbolic link. The path2 parameter may not name
an existing symbolic link.
The path2 parameter cannot name a hidden directory; new links can only be
explicitly named hidden directory components. If the path2 parameter is an
explicitly named hidden directory component, the path1 parameter cannot name a
hidden directory. If the path1 parameter references a hidden directory, the
current xvers string and the current site path are used to determine the file,
if any, to which the link is made.
RETURN VALUE
Upon successful completion, link returns a value of 0. If link fails, a value
of -1 is returned and errno is set to indicate the error.
ERROR CONDITIONS
The link system call fails if one or more of the following are true:
ENOTDIR A component of either path prefix is not a directory.
ENOENT A component of either path prefix does not exist.
EACCES A component of either path prefix denies search permission.
Processed November 7, 1990 LINK(2,L) 1
LINK(2,L) AIX Technical Reference LINK(2,L)
ENOENT The file named by the path1 parameter does not exist.
EEXIST The link named by the path2 parameter already exists.
EPERM The file named by the path1 parameter is a directory and the
effective user ID is not superuser.
EXDEV The link named by the path2 parameter and the file named by the path1
parameter are on different file systems.
ENOENT The path2 parameter points to a null path name.
EACCES The requested link requires writing in a directory with a mode that
denies write permission.
EROFS The requested link requires writing in a directory on a read-only
file system.
EFAULT The path1 or path2 parameter points to a location outside of the
process's allocated address space.
EDQUOT The directory in which the entry for the new link is being placed
cannot be extended because the user's quota of disk blocks on the
file system containing the directory has been exhausted.
EMLINK The file already has the maximum number of links.
ESTALE The process's root or current directory is located in an NFS virtual
file system that has been unmounted.
ENAMETOOLONG
A component of the path1 or path2 parameter exceeded NAME_MAX
characters or the entire path parameter exceeded PATH_MAX characters.
EACCES The path1 parameter names a directory and path2 names a component of
a hidden directory.
ENOENT A hidden directory was named by the path1 parameter, but no component
inside it matched the process's current site path list.
ENOENT A symbolic link was named by the path1 parameter or the path prefix
of the path2 parameter, but the file to which it refers does not
exist.
ELOOP A loop of symbolic links was detected.
ENOSPC The file system is out of inodes.
ENFILE The system inode table is full.
If the Transparent Computing Facility is installed on your system, link can
also fail if one or more of the following are true:
Processed November 7, 1990 LINK(2,L) 2
LINK(2,L) AIX Technical Reference LINK(2,L)
ESITEDN1 path1 or path2 cannot be accessed because a site went down.
ESITEDN2 The operation was terminated because a site failed.
ENOSTORE A component of path1 or path2 is replicated but not stored on any
site which is currently up.
EROFS Write access is requested for a directory on a replicated file system
in which the primary copy is unavailable.
EINTR A signal was caught during the link system call.
RELATED INFORMATION
In this book: "unlink, rmslink, remove."
The link command in AIX Operating System Commands Reference.
Processed November 7, 1990 LINK(2,L) 3