up | Inhaltsverzeichniss | Kommentar

Manual page for LINK(2V)

link - make a hard link to a file

SYNOPSIS

int link(path1, path2)
char *path1, *path2;

DESCRIPTION

path1 points to a pathname naming an existing file. path2 points to a pathname naming a new directory entry to be created. link() atomically creates a new link for the existing file and increments the link count of the file by one. {LINK_MAX} (see pathconf.2v specifies the maximum allowed number of links to the file.

With hard links, both files must be on the same file system. Both the old and the new link share equal access and rights to the underlying object. The super-user may make multiple links to a directory. Unless the caller is the super-user, the file named by path1 must not be a directory.

Upon successful completion, link() marks for update the st_ctime field of the file. Also, the st_ctime and st_mtime fields of the directory that contains the new entry are marked for update.

RETURN VALUES

link() returns:

0
on success.
-1
on failure and sets errno to indicate the error.

ERRORS

link() will fail and no link will be created if one or more of the following are true:

EACCES
Search permission is denied for a component of the path prefix pointed to by path1 or path2.

The requested link requires writing in a directory for which write permission is denied.

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.
EEXIST
The link referred to by path2 exists.
EFAULT
One of the path names specified is outside the process's allocated address space.
EIO
An I/O error occurred while reading from or writing to the file system to make the directory entry.
ELOOP
Too many symbolic links were encountered in translating the pathname pointed to by path1 or path2.
EMLINK
The number of links to the file named by path1 would exceed {LINK_MAX} (see pathconf.2v
ENAMETOOLONG
The length of the path argument exceeds {PATH_MAX}.

A pathname component is longer than {NAME_MAX} while {_POSIX_NO_TRUNC} is in effect (see pathconf.2v

ENOENT
A component of the path prefix pointed to by path1 or path2 does not exist.

The file referred to by path1 does not exist.

ENOSPC
The directory in which the entry for the new link is being placed cannot be extended because there is no space left on the file system containing the directory.
ENOTDIR
A component of the path prefix of path1 or path2 is not a directory.
EPERM
The file named by path1 is a directory and the effective user ID is not super-user.
EROFS
The requested link requires writing in a directory on a read-only file system.
EXDEV
The link named by path2 and the file named by path1 are on different file systems.

SYSTEM V ERRORS

In addition to the above, the following may also occur:

ENOENT
path1 or path2 points to an empty string.

SEE ALSO

symlink.2 unlink.2v


index | Inhaltsverzeichniss | Kommentar

Created by unroff & hp-tools. © somebody (See intro for details). All Rights Reserved. Last modified 11/5/97