161181Sbostic.\" Copyright (c) 1980, 1991, 1993 261181Sbostic.\" The Regents of the University of California. All rights reserved. 320035Smckusick.\" 447208Scael.\" %sccs.include.redist.man% 520035Smckusick.\" 6*65703Smckusick.\" @(#)link.2 8.3 (Berkeley) 01/12/94 747208Scael.\" 847208Scael.Dd 947208Scael.Dt LINK 2 1047208Scael.Os BSD 4 1147208Scael.Sh NAME 1247208Scael.Nm link 1347208Scael.Nd make a hard file link 1447208Scael.Sh SYNOPSIS 1547208Scael.Fd #include <unistd.h> 1647208Scael.Ft int 1747208Scael.Fn link "const char *name1" "const char *name2" 1847208Scael.Sh DESCRIPTION 1947208ScaelThe 2047208Scael.Fn link 2147208Scaelfunction call 2247208Scaelatomically creates the specified directory entry (hard link) 2347208Scael.Fa name2 2447208Scaelwith the attributes of the underlying object pointed at by 2547208Scael.Fa name1 2647208ScaelIf the link is successful: the link count of the underlying object 2747208Scaelis incremented; 2847208Scael.Fa name1 2947208Scaeland 3047208Scael.Fa name2 3147208Scaelshare equal access and rights 3247208Scaelto the 3347208Scaelunderlying object. 3447208Scael.Pp 3547208ScaelIf 3647208Scael.Fa name1 3747208Scaelis removed, the file 3847208Scael.Fa name2 3947208Scaelis not deleted and the link count of the 4047208Scaelunderlying object is 4147208Scaeldecremented. 4247208Scael.Pp 4347208Scael.Fa Name1 4447208Scaelmust exist for the hard link to 4547208Scaelsucceed and 4620036Smckusickboth 4747208Scael.Fa name1 4820036Smckusickand 4947208Scael.Fa name2 5020036Smckusickmust be in the same file system. 5120036SmckusickUnless the caller is the super-user, 5247208Scael.Fa name1 5347208Scaelmay not be a directory. 5447208Scael.Sh RETURN VALUES 5520036SmckusickUpon successful completion, a value of 0 is returned. Otherwise, 5647208Scaela value of -1 is returned and 5747208Scael.Va errno 5820036Smckusickis set to indicate the error. 5947208Scael.Sh ERRORS 6047208Scael.Fn Link 6147208Scaelwill fail and no link will be created if: 6247208Scael.Bl -tag -width Ar 6347208Scael.It Bq Er ENOTDIR 6420036SmckusickA component of either path prefix is not a directory. 6547208Scael.It Bq Er EINVAL 6621003SmckusickEither pathname contains a character with the high-order bit set. 6747208Scael.It Bq Er ENAMETOOLONG 6821003SmckusickA component of either pathname exceeded 255 characters, 6921003Smckusickor entire length of either path name exceeded 1023 characters. 7047208Scael.It Bq Er ENOENT 7120036SmckusickA component of either path prefix does not exist. 7247208Scael.It Bq Er EACCES 7320036SmckusickA component of either path prefix denies search permission. 7447208Scael.It Bq Er EACCES 7521003SmckusickThe requested link requires writing in a directory with a mode 7621003Smckusickthat denies write permission. 7747208Scael.It Bq Er ELOOP 7821003SmckusickToo many symbolic links were encountered in translating one of the pathnames. 7947208Scael.It Bq Er ENOENT 8047208ScaelThe file named by 8147208Scael.Fa name1 8247208Scaeldoes not exist. 8347208Scael.It Bq Er EEXIST 8447208ScaelThe link named by 8547208Scael.Fa name2 8647208Scaeldoes exist. 8747208Scael.It Bq Er EPERM 8847208ScaelThe file named by 8947208Scael.Fa name1 9047208Scaelis a directory and the effective 9120036Smckusickuser ID is not super-user. 9247208Scael.It Bq Er EXDEV 9347208ScaelThe link named by 9447208Scael.Fa name2 9547208Scaeland the file named by 9647208Scael.Fa name1 9720036Smckusickare on different file systems. 9847208Scael.It Bq Er ENOSPC 9924439SmckusickThe directory in which the entry for the new link is being placed 10024439Smckusickcannot be extended because there is no space left on the file 10124439Smckusicksystem containing the directory. 102*65703Smckusick.ne 3v 10347208Scael.It Bq Er EDQUOT 10424439SmckusickThe directory in which the entry for the new link 10524439Smckusickis being placed cannot be extended because the 10624439Smckusickuser's quota of disk blocks on the file system 10724439Smckusickcontaining the directory has been exhausted. 10847208Scael.It Bq Er EIO 10924439SmckusickAn I/O error occurred while reading from or writing to 11024439Smckusickthe file system to make the directory entry. 11147208Scael.It Bq Er EROFS 11220036SmckusickThe requested link requires writing in a directory on a read-only file 11320036Smckusicksystem. 11447208Scael.It Bq Er EFAULT 11520036SmckusickOne of the pathnames specified 11620036Smckusickis outside the process's allocated address space. 11747208Scael.El 11847208Scael.Sh SEE ALSO 11947208Scael.Xr symlink 2 , 12047208Scael.Xr unlink 2 12147208Scael.Sh STANDARDS 12247208Scael.Fn Link 12347208Scaelis expected to 12447208Scaelconform to IEEE Std 1003.1-1988 12547208Scael.Pq Dq Tn POSIX . 126