


      LINK(2)                     (UNIX 5.0)                    LINK(2)



      NAME
           link - link to a file

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

      DESCRIPTION
           Path1 points to a path name naming an existing file.  Path2
           points to a path name naming the new directory entry to be
           created.  Link creates a new link (directory entry) for the
           existing file.  Link fails and no link is created if one or
           more of the following are true:

                A component of either path prefix is not a directory.
                [ENOTDIR]

                A component of either path prefix does not exist.
                [ENOENT]

                A component of either path prefix denies search
                permission.  [EACCES]

                The file named by path1 does not exist.  [ENOENT]

                The link named by path2 exists.  [EEXIST]

                The file named by path1 is a directory and the
                effective user ID is not super-user.  [EPERM]

                The link named by path2 and the file named by path1 are
                on different logical devices (file systems).  [EXDEV]

                Path2 points to a null path name.  [ENOENT]

                The requested link requires writing in a directory with
                a mode that denies write permission.  [EACCES]

                The requested link requires writing in a directory on a
                read-only file system.  [EROFS]

                Path points outside the process's allocated address
                space.  [EFAULT]

      RETURN VALUE
           Upon successful completion, a value of 0 is returned.
           Otherwise, a value of -1 is returned and errno is set to
           indicate the error.

      SEE ALSO
           unlink(2).




      Page 1                                         (73 A2 02MTA REV1)






      LINK(2)                     (UNIX 5.0)                    LINK(2)



      BUGS
           Linking directories to parent directories can cause endless
           loops.




















































      Page 2                                         (73 A2 02MTA REV1)



