fixed the under development line
[unix-history] / usr / src / lib / libc / sys / link.2
CommitLineData
aaea5b2e
KB
1.\" Copyright (c) 1980, 1991, 1993
2.\" The Regents of the University of California. All rights reserved.
dd547749 3.\"
931b8415 4.\" %sccs.include.redist.man%
dd547749 5.\"
aaea5b2e 6.\" @(#)link.2 8.1 (Berkeley) %G%
931b8415
CL
7.\"
8.Dd
9.Dt LINK 2
10.Os BSD 4
11.Sh NAME
12.Nm link
13.Nd make a hard file link
14.Sh SYNOPSIS
15.Fd #include <unistd.h>
16.Ft int
17.Fn link "const char *name1" "const char *name2"
18.Sh DESCRIPTION
19The
20.Fn link
21function call
22atomically creates the specified directory entry (hard link)
23.Fa name2
24with the attributes of the underlying object pointed at by
25.Fa name1
26If the link is successful: the link count of the underlying object
27is incremented;
28.Fa name1
29and
30.Fa name2
31share equal access and rights
32to the
33underlying object.
34.Pp
35If
36.Fa name1
37is removed, the file
38.Fa name2
39is not deleted and the link count of the
40underlying object is
41decremented.
42.Pp
43.Fa Name1
44must exist for the hard link to
45succeed and
9142a5ba 46both
931b8415 47.Fa name1
9142a5ba 48and
931b8415 49.Fa name2
9142a5ba
KM
50must be in the same file system.
51Unless the caller is the super-user,
931b8415
CL
52.Fa name1
53may not be a directory.
54.Sh RETURN VALUES
9142a5ba 55Upon successful completion, a value of 0 is returned. Otherwise,
931b8415
CL
56a value of -1 is returned and
57.Va errno
9142a5ba 58is set to indicate the error.
931b8415
CL
59.Sh ERRORS
60.Fn Link
61will fail and no link will be created if:
9142a5ba 62are true:
931b8415
CL
63.Bl -tag -width Ar
64.It Bq Er ENOTDIR
9142a5ba 65A component of either path prefix is not a directory.
931b8415 66.It Bq Er EINVAL
b5984ffe 67Either pathname contains a character with the high-order bit set.
931b8415 68.It Bq Er ENAMETOOLONG
b5984ffe
KM
69A component of either pathname exceeded 255 characters,
70or entire length of either path name exceeded 1023 characters.
931b8415 71.It Bq Er ENOENT
9142a5ba 72A component of either path prefix does not exist.
931b8415 73.It Bq Er EACCES
9142a5ba 74A component of either path prefix denies search permission.
931b8415 75.It Bq Er EACCES
b5984ffe
KM
76The requested link requires writing in a directory with a mode
77that denies write permission.
931b8415 78.It Bq Er ELOOP
b5984ffe 79Too many symbolic links were encountered in translating one of the pathnames.
931b8415
CL
80.It Bq Er ENOENT
81The file named by
82.Fa name1
83does not exist.
84.It Bq Er EEXIST
85The link named by
86.Fa name2
87does exist.
88.It Bq Er EPERM
89The file named by
90.Fa name1
91is a directory and the effective
9142a5ba 92user ID is not super-user.
931b8415
CL
93.It Bq Er EXDEV
94The link named by
95.Fa name2
96and the file named by
97.Fa name1
9142a5ba 98are on different file systems.
931b8415 99.It Bq Er ENOSPC
fd690c8b
KM
100The directory in which the entry for the new link is being placed
101cannot be extended because there is no space left on the file
102system containing the directory.
931b8415 103.It Bq Er EDQUOT
fd690c8b
KM
104The directory in which the entry for the new link
105is being placed cannot be extended because the
106user's quota of disk blocks on the file system
107containing the directory has been exhausted.
931b8415 108.It Bq Er EIO
fd690c8b
KM
109An I/O error occurred while reading from or writing to
110the file system to make the directory entry.
931b8415 111.It Bq Er EROFS
9142a5ba
KM
112The requested link requires writing in a directory on a read-only file
113system.
931b8415 114.It Bq Er EFAULT
9142a5ba
KM
115One of the pathnames specified
116is outside the process's allocated address space.
931b8415
CL
117.El
118.Sh SEE ALSO
119.Xr symlink 2 ,
120.Xr unlink 2
121.Sh STANDARDS
122.Fn Link
123is expected to
124conform to IEEE Std 1003.1-1988
125.Pq Dq Tn POSIX .