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. All advertising materials mentioning features or use of this software
13 .\" must display the following acknowledgement:
14 .\" This product includes software developed by the University of
15 .\" California, Berkeley and its contributors.
16 .\" 4. Neither the name of the University nor the names of its contributors
17 .\" may be used to endorse or promote products derived from this software
18 .\" without specific prior written permission.
20 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 .\" @(#)link.2 8.3 (Berkeley) 1/12/94
33 .\" $FreeBSD: src/lib/libc/sys/link.2,v 1.11.2.7 2001/12/14 18:34:01 ru Exp $
34 .\" $DragonFly: src/lib/libc/sys/link.2,v 1.4 2007/04/26 17:35:03 swildner Exp $
41 .Nd make a hard file link
47 .Fn link "const char *name1" "const char *name2"
49 .Fn linkat "int fd1" "const char *name1" "int fd2" "const char *name2" "int flags"
54 atomically creates the specified directory entry (hard link)
56 with the attributes of the underlying object pointed at by
58 If the link is successful: the link count of the underlying object
63 share equal access and rights
71 is not deleted and the link count of the
76 must exist for the hard link to
82 must be in the same file system.
84 may not be a directory.
86 When operating on a symlink,
88 resolves the symlink and creates a hard link on the target.
94 but it will link on the symlink itself if the flag is clear.
98 system call is equivalent to
100 except in the case where either
104 or both are relative paths.
105 In this case a relative path
107 is interpreted relative to the directory associated with the file descriptor
109 instead of the current working directory and similarly for
111 and the file descriptor
117 has the special value
123 respectively is interpreted relative to the current working directory.
128 will fail and no link will be created if:
131 A component of either path prefix is not a directory.
132 .It Bq Er ENAMETOOLONG
133 A component of either pathname exceeded 255 characters,
134 or entire length of either path name exceeded 1023 characters.
136 A component of either path prefix does not exist.
138 The file system containing the file named by
140 does not support links.
142 The link count of the file named by
146 A component of either path prefix denies search permission.
148 The requested link requires writing in a directory with a mode
149 that denies write permission.
151 Too many symbolic links were encountered in translating one of the pathnames.
161 The named file has its immutable or append-only flag set (see
170 and the file named by
172 are on different file systems.
174 The directory in which the entry for the new link is being placed
175 cannot be extended because there is no space left on the file
176 system containing the directory.
178 The directory in which the entry for the new link
179 is being placed cannot be extended because the
180 user's quota of disk blocks on the file system
181 containing the directory has been exhausted.
183 An I/O error occurred while reading from or writing to
184 the file system to make the directory entry.
186 The requested link requires writing in a directory on a read-only file
189 One of the pathnames specified
190 is outside the process's allocated address space.
193 In addition to the errors returned by the
197 system call may fail if:
204 argument does not specify an absolute path and the
208 argument, respectively, is neither
210 nor a valid file descriptor open for searching.
216 argument is not an absolute path and
220 respectively, is neither
222 nor a file descriptor associated with a directory.
231 function call is expected to conform to
236 function call appeared in
240 system call appeared in
245 system call traditionally allows the super-user to link directories which
246 corrupts the filesystem coherency. This implementation no longer permits