]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - lib/libc/sys/fhlink.2
fhlink(2): the syscalls do not take flag
[FreeBSD/FreeBSD.git] / lib / libc / sys / fhlink.2
1 .\" SPDX-License-Identifier: BSD-2-Clause
2 .\"
3 .\" Copyright (c) 2018 Gandi
4 .\"
5 .\" Redistribution and use in source and binary forms, with or without
6 .\" modification, are permitted provided that the following conditions
7 .\" are met:
8 .\" 1. Redistributions of source code must retain the above copyright
9 .\"    notice, this list of conditions and the following disclaimer.
10 .\" 2. Redistributions in binary form must reproduce the above copyright
11 .\"    notice, this list of conditions and the following disclaimer in the
12 .\"    documentation and/or other materials provided with the distribution.
13 .\"
14 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 .\" SUCH DAMAGE.
25 .\"
26 .\" $FreeBSD$
27 .\"
28 .Dd February 23, 2021
29 .Dt FHLINK 2
30 .Os
31 .Sh NAME
32 .Nm fhlink ,
33 .Nm fhlinkat
34 .Nd make a hard file link
35 .Sh LIBRARY
36 .Lb libc
37 .Sh SYNOPSIS
38 .In unistd.h
39 .Ft int
40 .Fn fhlink "fhandle_t *fhp" "const char *to"
41 .Ft int
42 .Fn fhlinkat "fhandle_t *fhp" "int tofd" "const char *to"
43 .Fc
44 .Sh DESCRIPTION
45 The
46 .Fn fhlink
47 system call
48 atomically creates the specified directory entry (hard link)
49 .Fa to
50 with the attributes of the underlying object pointed at by
51 .Fa fhp .
52 If the link is successful: the link count of the underlying object
53 is incremented;
54 .Fa fhp
55 and
56 .Fa to
57 share equal access and rights
58 to the
59 underlying object.
60 .Pp
61 If
62 .Fa fhp
63 is removed, the file
64 .Fa to
65 is not deleted and the link count of the
66 underlying object is
67 decremented.
68 .Pp
69 The object pointed at by the
70 .Fa fhp
71 argument
72 must exist for the hard link to
73 succeed and
74 both
75 .Fa fhp
76 and
77 .Fa to
78 must be in the same file system.
79 The
80 .Fa fhp
81 argument
82 may not be a directory.
83 .Pp
84 The
85 .Fn fhlinkat
86 system call is equivalent to
87 .Fa fhlink
88 except in the case where
89 .Fa to
90 is a relative paths.
91 In this case a relative path
92 .Fa to
93 is interpreted relative to
94 the directory associated with the file descriptor
95 .Fa tofd
96 instead of the current working directory.
97 .Pp
98 If
99 .Fn fhlinkat
100 is passed the special value
101 .Dv AT_FDCWD
102 in the
103 .Fa tofd
104 parameter, the current working directory is used for the
105 .Fa to
106 argument.
107 If
108 .Fa tofd
109 has value
110 .Dv AT_FDCWD ,
111 the behavior is identical to a call to
112 .Fn link .
113 Unless
114 .Fa flag
115 contains the
116 .Dv AT_SYMLINK_FOLLOW
117 flag, if
118 .Fa fhp
119 names a symbolic link, a new link is created for the symbolic link
120 .Fa fhp
121 and not its target.
122 .Sh RETURN VALUES
123 .Rv -std link
124 .Sh ERRORS
125 The
126 .Fn fhlink
127 system call
128 will fail and no link will be created if:
129 .Bl -tag -width Er
130 .It Bq Er ENOTDIR
131 A component of
132 .Fa to
133 prefix is not a directory.
134 .It Bq Er ENAMETOOLONG
135 A component of
136 .Fa to
137 exceeded 255 characters,
138 or entire length of
139 .Fa to
140 name exceeded 1023 characters.
141 .It Bq Er ENOENT
142 A component of
143 .Fa to
144 prefix does not exist.
145 .It Bq Er EOPNOTSUPP
146 The file system containing the file pointed at by
147 .Fa fhp
148 does not support links.
149 .It Bq Er EMLINK
150 The link count of the file pointed at by
151 .Fa fhp
152 would exceed 32767.
153 .It Bq Er EACCES
154 A component of
155 .Fa to
156 prefix denies search permission.
157 .It Bq Er EACCES
158 The requested link requires writing in a directory with a mode
159 that denies write permission.
160 .It Bq Er ELOOP
161 Too many symbolic links were encountered in translating one of the pathnames.
162 .It Bq Er ENOENT
163 The file pointed at by
164 .Fa fhp
165 does not exist.
166 .It Bq Er EEXIST
167 The link named by
168 .Fa to
169 does exist.
170 .It Bq Er EPERM
171 The file pointed at by
172 .Fa fhp
173 is a directory.
174 .It Bq Er EPERM
175 The file pointed at by
176 .Fa fhp
177 has its immutable or append-only flag set, see the
178 .Xr chflags 2
179 manual page for more information.
180 .It Bq Er EPERM
181 The parent directory of the file named by
182 .Fa to
183 has its immutable flag set.
184 .It Bq Er EXDEV
185 The link named by
186 .Fa to
187 and the file pointed at by
188 .Fa fhp
189 are on different file systems.
190 .It Bq Er ENOSPC
191 The directory in which the entry for the new link is being placed
192 cannot be extended because there is no space left on the file
193 system containing the directory.
194 .It Bq Er EDQUOT
195 The directory in which the entry for the new link
196 is being placed cannot be extended because the
197 user's quota of disk blocks on the file system
198 containing the directory has been exhausted.
199 .It Bq Er EIO
200 An I/O error occurred while reading from or writing to
201 the file system to make the directory entry.
202 .It Bq Er EINTEGRITY
203 Corrupted data was detected while reading from the file system.
204 .It Bq Er EROFS
205 The requested link requires writing in a directory on a read-only file
206 system.
207 .It Bq Er EFAULT
208 One of the pathnames specified
209 is outside the process's allocated address space.
210 .It Bq Er ESTALE
211 The file handle
212 .Fa fhp
213 is no longer valid
214 .El
215 .Pp
216 In addition to the errors returned by the
217 .Fn fhlink ,
218 the
219 .Fn fhlinkat
220 system call may fail if:
221 .Bl -tag -width Er
222 .It Bq Er EBADF
223 The
224 .Fa fhp
225 or
226 .Fa to
227 argument does not specify an absolute path and the
228 .Fa tofd
229 argument, is not
230 .Dv AT_FDCWD
231 nor a valid file descriptor open for searching.
232 .It Bq Er EINVAL
233 The value of the
234 .Fa flag
235 argument is not valid.
236 .It Bq Er ENOTDIR
237 The
238 .Fa fhp
239 or
240 .Fa to
241 argument is not an absolute path and
242 .Fa tofd
243 is not
244 .Dv AT_FDCWD
245 nor a file descriptor associated with a directory.
246 .El
247 .Sh SEE ALSO
248 .Xr fhopen 2 ,
249 .Xr fhreadlink 2 ,
250 .Xr fhstat 2