unixdev.net


Switch to SpeakEasy.net DSL

The Modular Manual Browser

Home Page
Manual: (SunOS-4.1.3)
Page:
Section:
Apropos / Subsearch:
optional field

LINK(2V)                                                              LINK(2V)



NAME
       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  maxi-
       mum 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 fol-
       lowing 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 con-
                           taining 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 trans-
                           lating 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  path-
                           conf(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)



                                21 January 1990                       LINK(2V)