1 .\" Copyright (c) 1980, 1991, 1993
2 .\" The Regents of the University of California. All rights reserved.
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\" notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\" notice, this list of conditions and the following disclaimer in the
11 .\" documentation and/or other materials provided with the distribution.
12 .\" 3. Neither the name of the University nor the names of its contributors
13 .\" may be used to endorse or promote products derived from this software
14 .\" without specific prior written permission.
16 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
17 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
20 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 .\" @(#)link.2 8.3 (Berkeley) 1/12/94
31 .Dd September 23, 2020
37 .Nd make a hard file link
43 .Fn link "const char *name1" "const char *name2"
46 .Fa "int fd1" "const char *name1" "int fd2" "const char *name2" "int flag"
52 atomically creates the specified directory entry (hard link)
54 with the attributes of the underlying object pointed at by
56 If the link is successful: the link count of the underlying object
61 share equal access and rights
69 is not deleted and the link count of the
73 The object pointed at by the
76 must exist for the hard link to
82 must be in the same file system.
86 may not be a directory.
90 system call is equivalent to
92 except in the case where either
96 or both are relative paths.
97 In this case a relative path
99 is interpreted relative to
100 the directory associated with the file descriptor
102 instead of the current working directory and similarly for
104 and the file descriptor
109 are constructed by a bitwise-inclusive OR of flags from the following
112 .Bl -tag -width indent
113 .It Dv AT_SYMLINK_FOLLOW
116 names a symbolic link, a new link for the target of the symbolic link is
119 Only allow to link to a file which is beneath of the topping directory.
120 See the description of the
125 .It Dv AT_RESOLVE_BENEATH
126 Only walks paths below the topping directory.
127 See the description of the
128 .Dv O_RESOLVE_BENEATH
136 is passed the special value
142 parameter, the current working directory is used for the respective
151 the behavior is identical to a call to
156 .Dv AT_SYMLINK_FOLLOW
159 names a symbolic link, a new link is created for the symbolic link
168 will fail and no link will be created if:
171 A component of either path prefix is not a directory.
172 .It Bq Er ENAMETOOLONG
173 A component of either pathname exceeded 255 characters,
174 or entire length of either path name exceeded 1023 characters.
176 A component of either path prefix does not exist.
178 The file system containing the file named by
180 does not support links.
182 The link count of the file named by
186 A component of either path prefix denies search permission.
188 The requested link requires writing in a directory with a mode
189 that denies write permission.
191 Too many symbolic links were encountered in translating one of the pathnames.
207 has its immutable or append-only flag set, see the
209 manual page for more information.
211 The parent directory of the file named by
213 has its immutable flag set.
217 and the file named by
219 are on different file systems.
221 The directory in which the entry for the new link is being placed
222 cannot be extended because there is no space left on the file
223 system containing the directory.
225 The directory in which the entry for the new link
226 is being placed cannot be extended because the
227 user's quota of disk blocks on the file system
228 containing the directory has been exhausted.
230 An I/O error occurred while reading from or writing to
231 the file system to make the directory entry.
233 Corrupted data was detected while reading from the file system.
235 The requested link requires writing in a directory on a read-only file
238 One of the pathnames specified
239 is outside the process's allocated address space.
242 In addition to the errors returned by the
246 system call may fail if:
253 argument does not specify an absolute path and the
257 argument, respectively, is neither
259 nor a valid file descriptor open for searching.
263 argument is not valid.
269 argument is not an absolute path and
273 respectively, is neither
275 nor a file descriptor associated with a directory.
276 .It Bq Er ENOTCAPABLE
278 is not strictly relative to the starting directory.
281 is absolute or includes a ".." component that escapes
282 the directory hierarchy specified by
284 and the process is in capability mode.
285 .It Bq Er ENOTCAPABLE
290 and the absolute path
292 does not have its tail fully contained under the topping directory,
305 system call is expected to conform to
309 system call follows The Open Group Extended API Set 2 specification.
317 system call appeared in
322 system call traditionally allows the super-user to link directories which
323 corrupts the file system coherency.
324 This implementation no longer permits it.