Commit | Line | Data |
---|---|---|
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 | |
19 | The | |
20 | .Fn link | |
21 | function call | |
22 | atomically creates the specified directory entry (hard link) | |
23 | .Fa name2 | |
24 | with the attributes of the underlying object pointed at by | |
25 | .Fa name1 | |
26 | If the link is successful: the link count of the underlying object | |
27 | is incremented; | |
28 | .Fa name1 | |
29 | and | |
30 | .Fa name2 | |
31 | share equal access and rights | |
32 | to the | |
33 | underlying object. | |
34 | .Pp | |
35 | If | |
36 | .Fa name1 | |
37 | is removed, the file | |
38 | .Fa name2 | |
39 | is not deleted and the link count of the | |
40 | underlying object is | |
41 | decremented. | |
42 | .Pp | |
43 | .Fa Name1 | |
44 | must exist for the hard link to | |
45 | succeed and | |
9142a5ba | 46 | both |
931b8415 | 47 | .Fa name1 |
9142a5ba | 48 | and |
931b8415 | 49 | .Fa name2 |
9142a5ba KM |
50 | must be in the same file system. |
51 | Unless the caller is the super-user, | |
931b8415 CL |
52 | .Fa name1 |
53 | may not be a directory. | |
54 | .Sh RETURN VALUES | |
9142a5ba | 55 | Upon successful completion, a value of 0 is returned. Otherwise, |
931b8415 CL |
56 | a value of -1 is returned and |
57 | .Va errno | |
9142a5ba | 58 | is set to indicate the error. |
931b8415 CL |
59 | .Sh ERRORS |
60 | .Fn Link | |
61 | will fail and no link will be created if: | |
9142a5ba | 62 | are true: |
931b8415 CL |
63 | .Bl -tag -width Ar |
64 | .It Bq Er ENOTDIR | |
9142a5ba | 65 | A component of either path prefix is not a directory. |
931b8415 | 66 | .It Bq Er EINVAL |
b5984ffe | 67 | Either pathname contains a character with the high-order bit set. |
931b8415 | 68 | .It Bq Er ENAMETOOLONG |
b5984ffe KM |
69 | A component of either pathname exceeded 255 characters, |
70 | or entire length of either path name exceeded 1023 characters. | |
931b8415 | 71 | .It Bq Er ENOENT |
9142a5ba | 72 | A component of either path prefix does not exist. |
931b8415 | 73 | .It Bq Er EACCES |
9142a5ba | 74 | A component of either path prefix denies search permission. |
931b8415 | 75 | .It Bq Er EACCES |
b5984ffe KM |
76 | The requested link requires writing in a directory with a mode |
77 | that denies write permission. | |
931b8415 | 78 | .It Bq Er ELOOP |
b5984ffe | 79 | Too many symbolic links were encountered in translating one of the pathnames. |
931b8415 CL |
80 | .It Bq Er ENOENT |
81 | The file named by | |
82 | .Fa name1 | |
83 | does not exist. | |
84 | .It Bq Er EEXIST | |
85 | The link named by | |
86 | .Fa name2 | |
87 | does exist. | |
88 | .It Bq Er EPERM | |
89 | The file named by | |
90 | .Fa name1 | |
91 | is a directory and the effective | |
9142a5ba | 92 | user ID is not super-user. |
931b8415 CL |
93 | .It Bq Er EXDEV |
94 | The link named by | |
95 | .Fa name2 | |
96 | and the file named by | |
97 | .Fa name1 | |
9142a5ba | 98 | are on different file systems. |
931b8415 | 99 | .It Bq Er ENOSPC |
fd690c8b KM |
100 | The directory in which the entry for the new link is being placed |
101 | cannot be extended because there is no space left on the file | |
102 | system containing the directory. | |
931b8415 | 103 | .It Bq Er EDQUOT |
fd690c8b KM |
104 | The directory in which the entry for the new link |
105 | is being placed cannot be extended because the | |
106 | user's quota of disk blocks on the file system | |
107 | containing the directory has been exhausted. | |
931b8415 | 108 | .It Bq Er EIO |
fd690c8b KM |
109 | An I/O error occurred while reading from or writing to |
110 | the file system to make the directory entry. | |
931b8415 | 111 | .It Bq Er EROFS |
9142a5ba KM |
112 | The requested link requires writing in a directory on a read-only file |
113 | system. | |
931b8415 | 114 | .It Bq Er EFAULT |
9142a5ba KM |
115 | One of the pathnames specified |
116 | is 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 | |
123 | is expected to | |
124 | conform to IEEE Std 1003.1-1988 | |
125 | .Pq Dq Tn POSIX . |