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
29 .\" $FreeBSD: src/lib/libc/sys/link.2,v 1.11.2.7 2001/12/14 18:34:01 ru Exp $
37 .Nd make a hard file link
43 .Fn link "const char *name1" "const char *name2"
45 .Fn linkat "int fd1" "const char *name1" "int fd2" "const char *name2" "int flags"
50 atomically creates the specified directory entry (hard link)
52 with the attributes of the underlying object pointed at by
54 If the link is successful: the link count of the underlying object
59 share equal access and rights
67 is not deleted and the link count of the
72 must exist for the hard link to
78 must be in the same file system.
80 may not be a directory.
82 When operating on a symlink,
84 resolves the symlink and creates a hard link on the target.
90 but it will link on the symlink itself if the flag is clear.
94 system call is equivalent to
96 except in the case where either
100 or both are relative paths.
101 In this case a relative path
103 is interpreted relative to the directory associated with the file descriptor
105 instead of the current working directory and similarly for
107 and the file descriptor
113 has the special value
119 respectively is interpreted relative to the current working directory.
124 will fail and no link will be created if:
127 A component of either path prefix is not a directory.
128 .It Bq Er ENAMETOOLONG
129 A component of either pathname exceeded 255 characters,
130 or entire length of either path name exceeded 1023 characters.
132 A component of either path prefix does not exist.
134 The file system containing the file named by
136 does not support links.
138 The link count of the file named by
142 A component of either path prefix denies search permission.
144 The requested link requires writing in a directory with a mode
145 that denies write permission.
147 Too many symbolic links were encountered in translating one of the pathnames.
157 The named file has its immutable or append-only flag set (see
166 and the file named by
168 are on different file systems.
170 The directory in which the entry for the new link is being placed
171 cannot be extended because there is no space left on the file
172 system containing the directory.
174 The directory in which the entry for the new link
175 is being placed cannot be extended because the
176 user's quota of disk blocks on the file system
177 containing the directory has been exhausted.
179 An I/O error occurred while reading from or writing to
180 the file system to make the directory entry.
182 The requested link requires writing in a directory on a read-only file
185 One of the pathnames specified
186 is outside the process's allocated address space.
189 In addition to the errors returned by the
193 system call may fail if:
200 argument does not specify an absolute path and the
204 argument, respectively, is neither
206 nor a valid file descriptor open for searching.
212 argument is not an absolute path and
216 respectively, is neither
218 nor a file descriptor associated with a directory.
227 function call is expected to conform to
232 function call appeared in
236 system call appeared in
241 system call traditionally allows the super-user to link directories which
242 corrupts the filesystem coherency. This implementation no longer permits