Debian Codegraph @

templates/man2/open_by_handle_at.2.pot

raw
1 # SOME DESCRIPTIVE TITLE
2 # Copyright (C) YEAR Free Software Foundation, Inc.
3 # This file is distributed under the same license as the PACKAGE package.
4 # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
5 #
6 #, fuzzy
7 msgid ""
8 msgstr ""
9 "Project-Id-Version: PACKAGE VERSION\n"
10 "POT-Creation-Date: 2026-06-05 06:33+0200\n"
11 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
12 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
13 "Language-Team: LANGUAGE <[email protected]>\n"
14 "Language: \n"
15 "MIME-Version: 1.0\n"
16 "Content-Type: text/plain; charset=UTF-8\n"
17 "Content-Transfer-Encoding: 8bit\n"
18
19 #. type: TH
20 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
21 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
22 #, no-wrap
23 msgid "open_by_handle_at"
24 msgstr ""
25
26 #. type: TH
27 #: archlinux debian-unstable opensuse-leap-16-1 opensuse-tumbleweed
28 #, no-wrap
29 msgid "2026-02-22"
30 msgstr ""
31
32 #. type: TH
33 #: archlinux debian-unstable
34 #, no-wrap
35 msgid "Linux man-pages 6.18"
36 msgstr ""
37
38 #. type: SH
39 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
40 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
41 #, no-wrap
42 msgid "NAME"
43 msgstr ""
44
45 #. type: Plain text
46 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
47 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
48 msgid ""
49 "name_to_handle_at, open_by_handle_at - obtain handle for a pathname and open "
50 "file via a handle"
51 msgstr ""
52
53 #. type: SH
54 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
55 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
56 #, no-wrap
57 msgid "LIBRARY"
58 msgstr ""
59
60 #. type: Plain text
61 #: archlinux debian-unstable fedora-44 fedora-rawhide mageia-cauldron
62 #: opensuse-leap-16-1 opensuse-tumbleweed
63 msgid "Standard C library (I<libc>,\\ I<-lc>)"
64 msgstr ""
65
66 #. type: SH
67 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
68 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
69 #, no-wrap
70 msgid "SYNOPSIS"
71 msgstr ""
72
73 #. type: Plain text
74 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
75 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
76 #, no-wrap
77 msgid ""
78 "B<#define _GNU_SOURCE> /* See feature_test_macros(7) */\n"
79 "B<#include E<lt>fcntl.hE<gt>>\n"
80 msgstr ""
81
82 #. type: Plain text
83 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
84 #: opensuse-tumbleweed
85 #, no-wrap
86 msgid ""
87 "B<int name_to_handle_at(int >I<dirfd>B<, const char *>I<path>B<,>\n"
88 "B< struct file_handle *>I<handle>B<,>\n"
89 "B< int *>I<mount_id>B<, int >I<flags>B<);>\n"
90 "B<int open_by_handle_at(int >I<mount_fd>B<, struct file_handle *>I<handle>B<,>\n"
91 "B< int >I<flags>B<);>\n"
92 msgstr ""
93
94 #. type: SH
95 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
96 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
97 #, no-wrap
98 msgid "DESCRIPTION"
99 msgstr ""
100
101 #. type: Plain text
102 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
103 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
104 msgid ""
105 "The B<name_to_handle_at>() and B<open_by_handle_at>() system calls split "
106 "the functionality of B<openat>(2) into two parts: B<name_to_handle_at>() "
107 "returns an opaque handle that corresponds to a specified file; "
108 "B<open_by_handle_at>() opens the file corresponding to a handle returned by "
109 "a previous call to B<name_to_handle_at>() and returns an open file "
110 "descriptor."
111 msgstr ""
112
113 #. type: SS
114 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
115 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
116 #, no-wrap
117 msgid "name_to_handle_at()"
118 msgstr ""
119
120 #. type: Plain text
121 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
122 #: opensuse-tumbleweed
123 msgid ""
124 "The B<name_to_handle_at>() system call returns a file handle and a mount ID "
125 "corresponding to the file specified by the I<dirfd> and I<path> arguments. "
126 "The file handle is returned via the argument I<handle>, which is a pointer "
127 "to a structure of the following form:"
128 msgstr ""
129
130 #. type: Plain text
131 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
132 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
133 #, no-wrap
134 msgid ""
135 "struct file_handle {\n"
136 " unsigned int handle_bytes; /* Size of f_handle [in, out] */\n"
137 " int handle_type; /* Handle type [out] */\n"
138 " unsigned char f_handle[0]; /* File identifier (sized by\n"
139 " caller) [out] */\n"
140 "};\n"
141 msgstr ""
142
143 #. type: Plain text
144 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
145 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
146 msgid ""
147 "It is the caller's responsibility to allocate the structure with a size "
148 "large enough to hold the handle returned in I<f_handle>. Before the call, "
149 "the I<handle_bytes> field should be initialized to contain the allocated "
150 "size for I<f_handle>. (The constant B<MAX_HANDLE_SZ>, defined in "
151 "I<E<lt>fcntl.hE<gt>>, specifies the maximum expected size for a file "
152 "handle. It is not a guaranteed upper limit as future filesystems may "
153 "require more space.) Upon successful return, the I<handle_bytes> field is "
154 "updated to contain the number of bytes actually written to I<f_handle>."
155 msgstr ""
156
157 #. type: Plain text
158 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
159 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
160 msgid ""
161 "The caller can discover the required size for the I<file_handle> structure "
162 "by making a call in which I<handle-E<gt>handle_bytes> is zero; in this case, "
163 "the call fails with the error B<EOVERFLOW> and I<handle-E<gt>handle_bytes> "
164 "is set to indicate the required size; the caller can then use this "
165 "information to allocate a structure of the correct size (see EXAMPLES "
166 "below). Some care is needed here as B<EOVERFLOW> can also indicate that no "
167 "file handle is available for this particular name in a filesystem which does "
168 "normally support file-handle lookup. This case can be detected when the "
169 "B<EOVERFLOW> error is returned without I<handle_bytes> being increased."
170 msgstr ""
171
172 #. type: Plain text
173 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
174 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
175 msgid ""
176 "Other than the use of the I<handle_bytes> field, the caller should treat the "
177 "I<file_handle> structure as an opaque data type: the I<handle_type> and "
178 "I<f_handle> fields can be used in a subsequent call to "
179 "B<open_by_handle_at>(). The caller can also use the opaque I<file_handle> "
180 "to compare the identity of filesystem objects that were queried at different "
181 "times and possibly at different paths. The B<fanotify>(7) subsystem can "
182 "report events with an information record containing a I<file_handle> to "
183 "identify the filesystem object."
184 msgstr ""
185
186 #. type: Plain text
187 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
188 #: opensuse-tumbleweed
189 msgid ""
190 "The I<flags> argument is a bit mask constructed by ORing together zero or "
191 "more of B<AT_HANDLE_FID>, B<AT_HANDLE_MNT_ID_UNIQUE>, "
192 "B<AT_HANDLE_CONNECTABLE>, B<AT_EMPTY_PATH>, and B<AT_SYMLINK_FOLLOW>, "
193 "described below."
194 msgstr ""
195
196 #. commit 96b2b072ee62be8ae68c8ecf14854c4d0505a8f8
197 #. type: Plain text
198 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
199 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
200 msgid ""
201 "When I<flags> contain the B<AT_HANDLE_FID> (since Linux 6.5) flag, the "
202 "caller indicates that the returned I<file_handle> is needed to identify the "
203 "filesystem object, and not for opening the file later, so it should be "
204 "expected that a subsequent call to B<open_by_handle_at>() with the returned "
205 "I<file_handle> may fail."
206 msgstr ""
207
208 #. commit 4356d575ef0f39a3e8e0ce0c40d84ce900ac3b61
209 #. type: Plain text
210 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
211 #: opensuse-tumbleweed
212 msgid ""
213 "When I<flags> contain the B<AT_HANDLE_MNT_ID_UNIQUE> (since Linux 6.12) "
214 "flag, the caller indicates that the width of the I<mount_id> buffer is at "
215 "least 64 bits, and then the mount id returned in that buffer is the unique "
216 "mount id as the one returned by B<statx>(2) with the B<STATX_MNT_ID_UNIQUE> "
217 "flag."
218 msgstr ""
219
220 #. commit a20853ab8296d4a8754482cb5e9adde8ab426a25
221 #. type: Plain text
222 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
223 #: opensuse-tumbleweed
224 msgid ""
225 "When I<flags> contain the B<AT_HANDLE_CONNECTABLE> (since Linux 6.13) flag, "
226 "the caller indicates that the returned I<file_handle> is needed to open a "
227 "file with known path later, so it should be expected that a subsequent call "
228 "to B<open_by_handle_at>() with the returned I<file_handle> may fail if the "
229 "file was moved, but otherwise, the path of the opened file is expected to be "
230 "visible from the I</proc/>pidI</fd/>* magic link. This flag can not be used "
231 "in combination with the flags B<AT_HANDLE_FID> and/or B<AT_EMPTY_PATH>."
232 msgstr ""
233
234 #. type: Plain text
235 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
236 #: opensuse-tumbleweed
237 msgid ""
238 "Together, the I<path> and I<dirfd> arguments identify the file for which a "
239 "handle is to be obtained. There are four distinct cases:"
240 msgstr ""
241
242 #. type: IP
243 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
244 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
245 #, no-wrap
246 msgid "\\[bu]"
247 msgstr ""
248
249 #. type: Plain text
250 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
251 #: opensuse-tumbleweed
252 msgid ""
253 "If I<path> is a nonempty string containing an absolute pathname, then a "
254 "handle is returned for the file referred to by that pathname. In this case, "
255 "I<dirfd> is ignored."
256 msgstr ""
257
258 #. type: Plain text
259 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
260 #: opensuse-tumbleweed
261 msgid ""
262 "If I<path> is a nonempty string containing a relative pathname and I<dirfd> "
263 "has the special value B<AT_FDCWD>, then I<path> is interpreted relative to "
264 "the current working directory of the caller, and a handle is returned for "
265 "the file to which it refers."
266 msgstr ""
267
268 #. type: Plain text
269 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
270 #: opensuse-tumbleweed
271 msgid ""
272 "If I<path> is a nonempty string containing a relative pathname and I<dirfd> "
273 "is a file descriptor referring to a directory, then I<path> is interpreted "
274 "relative to the directory referred to by I<dirfd>, and a handle is returned "
275 "for the file to which it refers. (See B<openat>(2) for an explanation of "
276 "why \"directory file descriptors\" are useful.)"
277 msgstr ""
278
279 #. type: Plain text
280 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
281 #: opensuse-tumbleweed
282 msgid ""
283 "If I<path> is an empty string and I<flags> specifies the value "
284 "B<AT_EMPTY_PATH>, then I<dirfd> can be an open file descriptor referring to "
285 "any type of file, or B<AT_FDCWD>, meaning the current working directory, and "
286 "a handle is returned for the file to which it refers."
287 msgstr ""
288
289 #. type: Plain text
290 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
291 #: opensuse-tumbleweed
292 msgid ""
293 "The I<mount_id> argument returns an identifier for the filesystem mount that "
294 "corresponds to I<path>. This corresponds to the first field in one of the "
295 "records in I</proc/self/mountinfo>. Opening the pathname in the fifth field "
296 "of that record yields a file descriptor for the mount point; that file "
297 "descriptor can be used in a subsequent call to B<open_by_handle_at>(). "
298 "I<mount_id> is returned both for a successful call and for a call that "
299 "results in the error B<EOVERFLOW>."
300 msgstr ""
301
302 #. type: Plain text
303 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
304 #: opensuse-tumbleweed
305 msgid ""
306 "By default, B<name_to_handle_at>() does not dereference I<path> if it is a "
307 "symbolic link, and thus returns a handle for the link itself. If "
308 "B<AT_SYMLINK_FOLLOW> is specified in I<flags>, I<path> is dereferenced if it "
309 "is a symbolic link (so that the call returns a handle for the file referred "
310 "to by the link)."
311 msgstr ""
312
313 #. commit 20fa19027286983ab2734b5910c4a687436e0c31
314 #. type: Plain text
315 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
316 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
317 msgid ""
318 "B<name_to_handle_at>() does not trigger a mount when the final component of "
319 "the pathname is an automount point. When a filesystem supports both file "
320 "handles and automount points, a B<name_to_handle_at>() call on an automount "
321 "point will return with error B<EOVERFLOW> without having increased "
322 "I<handle_bytes>. This can happen since Linux 4.13 with NFS when accessing a "
323 "directory which is on a separate filesystem on the server. In this case, "
324 "the automount can be triggered by adding a \"/\" to the end of the pathname."
325 msgstr ""
326
327 #. type: SS
328 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
329 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
330 #, no-wrap
331 msgid "open_by_handle_at()"
332 msgstr ""
333
334 #. type: Plain text
335 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
336 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
337 msgid ""
338 "The B<open_by_handle_at>() system call opens the file referred to by "
339 "I<handle>, a file handle returned by a previous call to "
340 "B<name_to_handle_at>()."
341 msgstr ""
342
343 #. type: Plain text
344 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
345 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
346 msgid ""
347 "The I<mount_fd> argument is a file descriptor for any object (file, "
348 "directory, etc.) in the mounted filesystem with respect to which I<handle> "
349 "should be interpreted. The special value B<AT_FDCWD> can be specified, "
350 "meaning the current working directory of the caller."
351 msgstr ""
352
353 #. type: Plain text
354 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
355 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
356 msgid ""
357 "The I<flags> argument is as for B<open>(2). If I<handle> refers to a "
358 "symbolic link, the caller must specify the B<O_PATH> flag, and the symbolic "
359 "link is not dereferenced; the B<O_NOFOLLOW> flag, if specified, is ignored."
360 msgstr ""
361
362 #. type: Plain text
363 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
364 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
365 msgid ""
366 "The caller must have the B<CAP_DAC_READ_SEARCH> capability to invoke "
367 "B<open_by_handle_at>()."
368 msgstr ""
369
370 #. type: SH
371 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
372 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
373 #, no-wrap
374 msgid "RETURN VALUE"
375 msgstr ""
376
377 #. type: Plain text
378 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
379 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
380 msgid ""
381 "On success, B<name_to_handle_at>() returns 0, and B<open_by_handle_at>() "
382 "returns a file descriptor (a nonnegative integer)."
383 msgstr ""
384
385 #. type: Plain text
386 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
387 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
388 msgid ""
389 "In the event of an error, both system calls return -1 and set I<errno> to "
390 "indicate the error."
391 msgstr ""
392
393 #. type: SH
394 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
395 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
396 #, no-wrap
397 msgid "ERRORS"
398 msgstr ""
399
400 #. type: Plain text
401 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
402 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
403 msgid ""
404 "B<name_to_handle_at>() and B<open_by_handle_at>() can fail for the same "
405 "errors as B<openat>(2). In addition, they can fail with the errors noted "
406 "below."
407 msgstr ""
408
409 #. type: Plain text
410 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
411 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
412 msgid "B<name_to_handle_at>() can fail with the following errors:"
413 msgstr ""
414
415 #. type: TP
416 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
417 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
418 #, no-wrap
419 msgid "B<EFAULT>"
420 msgstr ""
421
422 #. type: Plain text
423 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
424 #: opensuse-tumbleweed
425 msgid ""
426 "I<path>, I<mount_id>, or I<handle> points outside your accessible address "
427 "space."
428 msgstr ""
429
430 #. type: TP
431 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
432 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
433 #, no-wrap
434 msgid "B<EINVAL>"
435 msgstr ""
436
437 #. type: Plain text
438 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
439 #: opensuse-tumbleweed
440 msgid "I<flags> includes an invalid bit value or an invalid bit combination."
441 msgstr ""
442
443 #. type: Plain text
444 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
445 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
446 msgid "I<handle-E<gt>handle_bytes> is greater than B<MAX_HANDLE_SZ>."
447 msgstr ""
448
449 #. type: TP
450 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
451 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
452 #, no-wrap
453 msgid "B<ENOENT>"
454 msgstr ""
455
456 #. type: Plain text
457 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
458 #: opensuse-tumbleweed
459 msgid ""
460 "I<path> is an empty string, but B<AT_EMPTY_PATH> was not specified in "
461 "I<flags>."
462 msgstr ""
463
464 #. type: TP
465 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
466 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
467 #, no-wrap
468 msgid "B<ENOTDIR>"
469 msgstr ""
470
471 #. type: Plain text
472 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
473 #: opensuse-tumbleweed
474 msgid ""
475 "The file descriptor supplied in I<dirfd> does not refer to a directory, and "
476 "it is not the case that both I<flags> includes B<AT_EMPTY_PATH> and I<path> "
477 "is an empty string."
478 msgstr ""
479
480 #. type: TP
481 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
482 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
483 #, no-wrap
484 msgid "B<EOPNOTSUPP>"
485 msgstr ""
486
487 #. type: Plain text
488 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
489 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
490 msgid ""
491 "The filesystem does not support decoding of a pathname to a file handle."
492 msgstr ""
493
494 #. type: TP
495 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
496 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
497 #, no-wrap
498 msgid "B<EOVERFLOW>"
499 msgstr ""
500
501 #. type: Plain text
502 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
503 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
504 msgid ""
505 "The I<handle-E<gt>handle_bytes> value passed into the call was too small. "
506 "When this error occurs, I<handle-E<gt>handle_bytes> is updated to indicate "
507 "the required size for the handle."
508 msgstr ""
509
510 #. type: Plain text
511 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
512 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
513 msgid "B<open_by_handle_at>() can fail with the following errors:"
514 msgstr ""
515
516 #. type: TP
517 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
518 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
519 #, no-wrap
520 msgid "B<EBADF>"
521 msgstr ""
522
523 #. type: Plain text
524 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
525 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
526 msgid "I<mount_fd> is not an open file descriptor."
527 msgstr ""
528
529 #. type: Plain text
530 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
531 #: opensuse-tumbleweed
532 msgid ""
533 "I<path> is relative but I<dirfd> is neither B<AT_FDCWD> nor a valid file "
534 "descriptor."
535 msgstr ""
536
537 #. type: Plain text
538 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
539 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
540 msgid "I<handle> points outside your accessible address space."
541 msgstr ""
542
543 #. type: Plain text
544 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
545 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
546 msgid ""
547 "I<handle-E<gt>handle_bytes> is greater than B<MAX_HANDLE_SZ> or is equal to "
548 "zero."
549 msgstr ""
550
551 #. type: TP
552 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
553 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
554 #, no-wrap
555 msgid "B<ELOOP>"
556 msgstr ""
557
558 #. type: Plain text
559 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
560 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
561 msgid ""
562 "I<handle> refers to a symbolic link, but B<O_PATH> was not specified in "
563 "I<flags>."
564 msgstr ""
565
566 #. type: TP
567 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
568 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
569 #, no-wrap
570 msgid "B<EPERM>"
571 msgstr ""
572
573 #. type: Plain text
574 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
575 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
576 msgid "The caller does not have the B<CAP_DAC_READ_SEARCH> capability."
577 msgstr ""
578
579 #. type: TP
580 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
581 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
582 #, no-wrap
583 msgid "B<ESTALE>"
584 msgstr ""
585
586 #. type: Plain text
587 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
588 #: opensuse-tumbleweed
589 msgid ""
590 "The specified I<handle> is not valid for opening a file. This error will "
591 "occur if, for example, the file has been deleted. This error can also occur "
592 "if the I<handle> was acquired using the B<AT_HANDLE_FID> flag and the "
593 "filesystem does not support B<open_by_handle_at>(). This error can also "
594 "occur if the I<handle> was acquired using the B<AT_HANDLE_CONNECTABLE> flag "
595 "and the file was moved to a different parent."
596 msgstr ""
597
598 #. type: SH
599 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
600 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
601 #, no-wrap
602 msgid "VERSIONS"
603 msgstr ""
604
605 #. type: Plain text
606 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
607 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
608 msgid ""
609 "FreeBSD has a broadly similar pair of system calls in the form of "
610 "B<getfh>() and B<fhopen>()."
611 msgstr ""
612
613 #. type: SH
614 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
615 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
616 #, no-wrap
617 msgid "STANDARDS"
618 msgstr ""
619
620 #. type: Plain text
621 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
622 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
623 msgid "Linux."
624 msgstr ""
625
626 #. type: SH
627 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
628 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
629 #, no-wrap
630 msgid "HISTORY"
631 msgstr ""
632
633 #. type: Plain text
634 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
635 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
636 msgid "Linux 2.6.39, glibc 2.14."
637 msgstr ""
638
639 #. type: SH
640 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
641 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
642 #, no-wrap
643 msgid "NOTES"
644 msgstr ""
645
646 #. type: Plain text
647 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
648 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
649 msgid ""
650 "A file handle can be generated in one process using B<name_to_handle_at>() "
651 "and later used in a different process that calls B<open_by_handle_at>()."
652 msgstr ""
653
654 #. type: Plain text
655 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
656 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
657 msgid ""
658 "Some filesystem don't support the translation of pathnames to file handles, "
659 "for example, I</proc>, I</sys>, and various network filesystems. Some "
660 "filesystems support the translation of pathnames to file handles, but do not "
661 "support using those file handles in B<open_by_handle_at>()."
662 msgstr ""
663
664 #. type: Plain text
665 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
666 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
667 msgid ""
668 "A file handle may become invalid (\"stale\") if a file is deleted, or for "
669 "other filesystem-specific reasons. Invalid handles are notified by an "
670 "B<ESTALE> error from B<open_by_handle_at>()."
671 msgstr ""
672
673 #. https://lwn.net/Articles/375888/
674 #. "Open by handle" - Jonathan Corbet, 2010-02-23
675 #. type: Plain text
676 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
677 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
678 msgid ""
679 "These system calls are designed for use by user-space file servers. For "
680 "example, a user-space NFS server might generate a file handle and pass it to "
681 "an NFS client. Later, when the client wants to open the file, it could pass "
682 "the handle back to the server. This sort of functionality allows a user-"
683 "space file server to operate in a stateless fashion with respect to the "
684 "files it serves."
685 msgstr ""
686
687 #. commit bcda76524cd1fa32af748536f27f674a13e56700
688 #. type: Plain text
689 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
690 #: opensuse-tumbleweed
691 msgid ""
692 "If I<path> refers to a symbolic link and I<flags> does not specify "
693 "B<AT_SYMLINK_FOLLOW>, then B<name_to_handle_at>() returns a handle for the "
694 "link (rather than the file to which it refers). The process receiving the "
695 "handle can later perform operations on the symbolic link by converting the "
696 "handle to a file descriptor using B<open_by_handle_at>() with the B<O_PATH> "
697 "flag, and then passing the file descriptor as the I<dirfd> argument in "
698 "system calls such as B<readlinkat>(2) and B<fchownat>(2)."
699 msgstr ""
700
701 #. type: SS
702 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
703 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
704 #, no-wrap
705 msgid "Obtaining a persistent filesystem ID"
706 msgstr ""
707
708 #. type: Plain text
709 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
710 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
711 msgid ""
712 "The mount IDs in I</proc/self/mountinfo> can be reused as filesystems are "
713 "unmounted and mounted. Therefore, the mount ID returned by "
714 "B<name_to_handle_at>() (in I<*mount_id>) should not be treated as a "
715 "persistent identifier for the corresponding mounted filesystem. However, an "
716 "application can use the information in the I<mountinfo> record that "
717 "corresponds to the mount ID to derive a persistent identifier."
718 msgstr ""
719
720 #. e.g., http://stackoverflow.com/questions/6748429/using-libblkid-to-find-uuid-of-a-partition
721 #. type: Plain text
722 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
723 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
724 msgid ""
725 "For example, one can use the device name in the fifth field of the "
726 "I<mountinfo> record to search for the corresponding device UUID via the "
727 "symbolic links in I</dev/disks/by-uuid>. (A more comfortable way of "
728 "obtaining the UUID is to use the B<libblkid>(3) library.) That process can "
729 "then be reversed, using the UUID to look up the device name, and then "
730 "obtaining the corresponding mount point, in order to produce the I<mount_fd> "
731 "argument used by B<open_by_handle_at>()."
732 msgstr ""
733
734 #. type: SH
735 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
736 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
737 #, no-wrap
738 msgid "EXAMPLES"
739 msgstr ""
740
741 #. type: Plain text
742 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
743 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
744 msgid ""
745 "The two programs below demonstrate the use of B<name_to_handle_at>() and "
746 "B<open_by_handle_at>(). The first program (I<t_name_to_handle_at.c>) uses "
747 "B<name_to_handle_at>() to obtain the file handle and mount ID for the file "
748 "specified in its command-line argument; the handle and mount ID are written "
749 "to standard output."
750 msgstr ""
751
752 #. type: Plain text
753 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
754 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
755 msgid ""
756 "The second program (I<t_open_by_handle_at.c>) reads a mount ID and file "
757 "handle from standard input. The program then employs "
758 "B<open_by_handle_at>() to open the file using that handle. If an optional "
759 "command-line argument is supplied, then the I<mount_fd> argument for "
760 "B<open_by_handle_at>() is obtained by opening the directory named in that "
761 "argument. Otherwise, I<mount_fd> is obtained by scanning I</proc/self/"
762 "mountinfo> to find a record whose mount ID matches the mount ID read from "
763 "standard input, and the mount directory specified in that record is opened. "
764 "(These programs do not deal with the fact that mount IDs are not persistent.)"
765 msgstr ""
766
767 #. type: Plain text
768 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
769 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
770 msgid "The following shell session demonstrates the use of these two programs:"
771 msgstr ""
772
773 #. type: Plain text
774 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
775 #: opensuse-tumbleweed
776 #, no-wrap
777 msgid ""
778 "$B< echo \\[aq]Can you please think about it?\\[aq] E<gt> cecilia.txt>;\n"
779 "$B< ./t_name_to_handle_at cecilia.txt E<gt> fh>;\n"
780 "$B< ./t_open_by_handle_at E<lt> fh>;\n"
781 "open_by_handle_at: Operation not permitted\n"
782 "$B< sudo ./t_open_by_handle_at E<lt> fh>; # Need CAP_SYS_ADMIN\n"
783 "Read 31 bytes\n"
784 "$B< rm cecilia.txt>;\n"
785 msgstr ""
786
787 #. Christoph Hellwig: That's why the file handles contain a generation
788 #. counter that gets incremented in this case.
789 #. type: Plain text
790 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
791 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
792 msgid ""
793 "Now we delete and (quickly) re-create the file so that it has the same "
794 "content and (by chance) the same inode. Nevertheless, "
795 "B<open_by_handle_at>() recognizes that the original file referred to by the "
796 "file handle no longer exists."
797 msgstr ""
798
799 #. type: Plain text
800 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
801 #: opensuse-tumbleweed
802 #, no-wrap
803 msgid ""
804 "$B< stat --printf=\\[dq]%i\\[rs]n\\[dq] cecilia.txt>; # Display inode number\n"
805 "4072121\n"
806 "$B< rm cecilia.txt>;\n"
807 "$B< echo \\[aq]Can you please think about it?\\[aq] E<gt> cecilia.txt>;\n"
808 "$B< stat --printf=\\[dq]%i\\[rs]n\\[dq] cecilia.txt>; # Check inode number\n"
809 "4072121\n"
810 "$B< sudo ./t_open_by_handle_at E<lt> fh>;\n"
811 "open_by_handle_at: Stale NFS file handle\n"
812 msgstr ""
813
814 #. type: SS
815 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
816 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
817 #, no-wrap
818 msgid "Program source: t_name_to_handle_at.c"
819 msgstr ""
820
821 #. type: Plain text
822 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
823 #: opensuse-tumbleweed
824 #, no-wrap
825 msgid ""
826 "#define _GNU_SOURCE\n"
827 "#include E<lt>err.hE<gt>\n"
828 "#include E<lt>errno.hE<gt>\n"
829 "#include E<lt>fcntl.hE<gt>\n"
830 "#include E<lt>stdio.hE<gt>\n"
831 "#include E<lt>stdlib.hE<gt>\n"
832 "\\&\n"
833 "int\n"
834 "main(int argc, char *argv[])\n"
835 "{\n"
836 " int mount_id, fhsize, flags, dirfd;\n"
837 " char *path;\n"
838 " struct file_handle *fhp;\n"
839 "\\&\n"
840 " if (argc != 2) {\n"
841 " fprintf(stderr, \"Usage: %s path\\[rs]n\", argv[0]);\n"
842 " exit(EXIT_FAILURE);\n"
843 " }\n"
844 "\\&\n"
845 " path = argv[1];\n"
846 "\\&\n"
847 " /* Allocate file_handle structure. */\n"
848 "\\&\n"
849 " fhsize = sizeof(*fhp);\n"
850 " fhp = malloc(fhsize);\n"
851 " if (fhp == NULL)\n"
852 " err(EXIT_FAILURE, \"malloc\");\n"
853 "\\&\n"
854 " /* Make an initial call to name_to_handle_at() to discover\n"
855 " the size required for file handle. */\n"
856 "\\&\n"
857 " dirfd = AT_FDCWD; /* For name_to_handle_at() calls */\n"
858 " flags = 0; /* For name_to_handle_at() calls */\n"
859 " fhp-E<gt>handle_bytes = 0;\n"
860 " if (name_to_handle_at(dirfd, path, fhp, &mount_id, flags) != -1\n"
861 " || errno != EOVERFLOW)\n"
862 " {\n"
863 " fprintf(stderr, \"Unexpected result from name_to_handle_at()\\[rs]n\");\n"
864 " exit(EXIT_FAILURE);\n"
865 " }\n"
866 "\\&\n"
867 " /* Reallocate file_handle structure with correct size. */\n"
868 "\\&\n"
869 " fhsize = sizeof(*fhp) + fhp-E<gt>handle_bytes;\n"
870 " fhp = realloc(fhp, fhsize); /* Copies fhp-E<gt>handle_bytes */\n"
871 " if (fhp == NULL)\n"
872 " err(EXIT_FAILURE, \"realloc\");\n"
873 "\\&\n"
874 " /* Get file handle from pathname supplied on command line. */\n"
875 "\\&\n"
876 " if (name_to_handle_at(dirfd, path, fhp, &mount_id, flags) == -1)\n"
877 " err(EXIT_FAILURE, \"name_to_handle_at\");\n"
878 "\\&\n"
879 " /* Write mount ID, file handle size, and file handle to stdout,\n"
880 " for later reuse by t_open_by_handle_at.c. */\n"
881 "\\&\n"
882 " printf(\"%d\\[rs]n\", mount_id);\n"
883 " printf(\"%u %d \", fhp-E<gt>handle_bytes, fhp-E<gt>handle_type);\n"
884 " for (size_t j = 0; j E<lt> fhp-E<gt>handle_bytes; j++)\n"
885 " printf(\" %02x\", fhp-E<gt>f_handle[j]);\n"
886 " printf(\"\\[rs]n\");\n"
887 "\\&\n"
888 " exit(EXIT_SUCCESS);\n"
889 "}\n"
890 msgstr ""
891
892 #. SRC END
893 #. type: SS
894 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
895 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
896 #, no-wrap
897 msgid "Program source: t_open_by_handle_at.c"
898 msgstr ""
899
900 #. type: Plain text
901 #: archlinux debian-unstable opensuse-leap-16-1 opensuse-tumbleweed
902 #, no-wrap
903 msgid ""
904 "#define _GNU_SOURCE\n"
905 "#include E<lt>err.hE<gt>\n"
906 "#include E<lt>fcntl.hE<gt>\n"
907 "#include E<lt>limits.hE<gt>\n"
908 "#include E<lt>stdio.hE<gt>\n"
909 "#include E<lt>stdlib.hE<gt>\n"
910 "#include E<lt>string.hE<gt>\n"
911 "#include E<lt>sys/types.hE<gt>\n"
912 "#include E<lt>unistd.hE<gt>\n"
913 "\\&\n"
914 "#define streq(...) (strcmp(__VA_ARGS__) == 0)\n"
915 "\\&\n"
916 "/* Scan /proc/self/mountinfo to find the line whose mount ID matches\n"
917 " \\[aq]mount_id\\[aq]. (An easier way to do this is to install and use the\n"
918 " \\[aq]libmount\\[aq] library provided by the \\[aq]util-linux\\[aq] project.)\n"
919 " Open the corresponding mount path and return the resulting file\n"
920 " descriptor. */\n"
921 "\\&\n"
922 "static int\n"
923 "open_mount_path_by_id(int mount_id)\n"
924 "{\n"
925 " int mi_mount_id, found;\n"
926 " char mount_path[PATH_MAX];\n"
927 " char *linep;\n"
928 " FILE *fp;\n"
929 " size_t lsize;\n"
930 " ssize_t nread;\n"
931 "\\&\n"
932 " fp = fopen(\"/proc/self/mountinfo\", \"r\");\n"
933 " if (fp == NULL)\n"
934 " err(EXIT_FAILURE, \"fopen\");\n"
935 "\\&\n"
936 " found = 0;\n"
937 " linep = NULL;\n"
938 " while (!found) {\n"
939 " nread = getline(&linep, &lsize, fp);\n"
940 " if (nread == -1)\n"
941 " break;\n"
942 "\\&\n"
943 " nread = sscanf(linep, \"%d %*d %*s %*s %s\",\n"
944 " &mi_mount_id, mount_path);\n"
945 " if (nread != 2) {\n"
946 " fprintf(stderr, \"Bad sscanf()\\[rs]n\");\n"
947 " exit(EXIT_FAILURE);\n"
948 " }\n"
949 "\\&\n"
950 " if (mi_mount_id == mount_id)\n"
951 " found = 1;\n"
952 " }\n"
953 " free(linep);\n"
954 "\\&\n"
955 " fclose(fp);\n"
956 "\\&\n"
957 " if (!found) {\n"
958 " fprintf(stderr, \"Could not find mount point\\[rs]n\");\n"
959 " exit(EXIT_FAILURE);\n"
960 " }\n"
961 "\\&\n"
962 " return open(mount_path, O_RDONLY);\n"
963 "}\n"
964 "\\&\n"
965 "int\n"
966 "main(int argc, char *argv[])\n"
967 "{\n"
968 " int mount_id, fd, mount_fd, handle_bytes;\n"
969 " char buf[1000];\n"
970 "#define LINE_SIZE 100\n"
971 " char line1[LINE_SIZE], line2[LINE_SIZE];\n"
972 " char *nextp;\n"
973 " ssize_t nread;\n"
974 " struct file_handle *fhp;\n"
975 "\\&\n"
976 " if ((argc E<gt> 1 && streq(argv[1], \"--help\")) || argc E<gt> 2) {\n"
977 " fprintf(stderr, \"Usage: %s [mount-path]\\[rs]n\", argv[0]);\n"
978 " exit(EXIT_FAILURE);\n"
979 " }\n"
980 "\\&\n"
981 " /* Standard input contains mount ID and file handle information:\n"
982 "\\&\n"
983 " Line 1: E<lt>mount_idE<gt>\n"
984 " Line 2: E<lt>handle_bytesE<gt> E<lt>handle_typeE<gt> E<lt>bytes of handle in hexE<gt>\n"
985 " */\n"
986 "\\&\n"
987 " if (fgets(line1, sizeof(line1), stdin) == NULL ||\n"
988 " fgets(line2, sizeof(line2), stdin) == NULL)\n"
989 " {\n"
990 " fprintf(stderr, \"Missing mount_id / file handle\\[rs]n\");\n"
991 " exit(EXIT_FAILURE);\n"
992 " }\n"
993 "\\&\n"
994 " mount_id = atoi(line1);\n"
995 "\\&\n"
996 " handle_bytes = strtoul(line2, &nextp, 0);\n"
997 "\\&\n"
998 " /* Given handle_bytes, we can now allocate file_handle structure. */\n"
999 "\\&\n"
1000 " fhp = malloc(sizeof(*fhp) + handle_bytes);\n"
1001 " if (fhp == NULL)\n"
1002 " err(EXIT_FAILURE, \"malloc\");\n"
1003 "\\&\n"
1004 " fhp-E<gt>handle_bytes = handle_bytes;\n"
1005 "\\&\n"
1006 " fhp-E<gt>handle_type = strtoul(nextp, &nextp, 0);\n"
1007 "\\&\n"
1008 " for (size_t j = 0; j E<lt> fhp-E<gt>handle_bytes; j++)\n"
1009 " fhp-E<gt>f_handle[j] = strtoul(nextp, &nextp, 16);\n"
1010 "\\&\n"
1011 " /* Obtain file descriptor for mount point, either by opening\n"
1012 " the pathname specified on the command line, or by scanning\n"
1013 " /proc/self/mounts to find a mount that matches the \\[aq]mount_id\\[aq]\n"
1014 " that we received from stdin. */\n"
1015 "\\&\n"
1016 " if (argc E<gt> 1)\n"
1017 " mount_fd = open(argv[1], O_RDONLY);\n"
1018 " else\n"
1019 " mount_fd = open_mount_path_by_id(mount_id);\n"
1020 "\\&\n"
1021 " if (mount_fd == -1)\n"
1022 " err(EXIT_FAILURE, \"opening mount fd\");\n"
1023 "\\&\n"
1024 " /* Open file using handle and mount point. */\n"
1025 "\\&\n"
1026 " fd = open_by_handle_at(mount_fd, fhp, O_RDONLY);\n"
1027 " if (fd == -1)\n"
1028 " err(EXIT_FAILURE, \"open_by_handle_at\");\n"
1029 "\\&\n"
1030 " /* Try reading a few bytes from the file. */\n"
1031 "\\&\n"
1032 " nread = read(fd, buf, sizeof(buf));\n"
1033 " if (nread == -1)\n"
1034 " err(EXIT_FAILURE, \"read\");\n"
1035 "\\&\n"
1036 " printf(\"Read %zd bytes\\[rs]n\", nread);\n"
1037 "\\&\n"
1038 " exit(EXIT_SUCCESS);\n"
1039 "}\n"
1040 msgstr ""
1041
1042 #. SRC END
1043 #. type: SH
1044 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1045 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1046 #, no-wrap
1047 msgid "SEE ALSO"
1048 msgstr ""
1049
1050 #. type: Plain text
1051 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1052 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1053 msgid "B<open>(2), B<libblkid>(3), B<blkid>(8), B<findfs>(8), B<mount>(8)"
1054 msgstr ""
1055
1056 #. type: Plain text
1057 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
1058 #: opensuse-tumbleweed
1059 msgid ""
1060 "The I<libblkid> and I<libmount> documentation in the latest I<util-linux> "
1061 "release at E<.UR https:\\://www.kernel.org/pub/linux/utils/util-linux/> "
1062 "E<.UE>"
1063 msgstr ""
1064
1065 #. type: TH
1066 #: debian-trixie
1067 #, no-wrap
1068 msgid "2024-06-15"
1069 msgstr ""
1070
1071 #. type: TH
1072 #: debian-trixie
1073 #, no-wrap
1074 msgid "Linux man-pages 6.9.1"
1075 msgstr ""
1076
1077 #. type: Plain text
1078 #: debian-trixie
1079 msgid "Standard C library (I<libc>, I<-lc>)"
1080 msgstr ""
1081
1082 #. type: Plain text
1083 #: debian-trixie fedora-44 fedora-rawhide
1084 #, no-wrap
1085 msgid ""
1086 "B<int name_to_handle_at(int >I<dirfd>B<, const char *>I<pathname>B<,>\n"
1087 "B< struct file_handle *>I<handle>B<,>\n"
1088 "B< int *>I<mount_id>B<, int >I<flags>B<);>\n"
1089 "B<int open_by_handle_at(int >I<mount_fd>B<, struct file_handle *>I<handle>B<,>\n"
1090 "B< int >I<flags>B<);>\n"
1091 msgstr ""
1092
1093 #. type: Plain text
1094 #: debian-trixie fedora-44 fedora-rawhide
1095 msgid ""
1096 "The B<name_to_handle_at>() system call returns a file handle and a mount ID "
1097 "corresponding to the file specified by the I<dirfd> and I<pathname> "
1098 "arguments. The file handle is returned via the argument I<handle>, which is "
1099 "a pointer to a structure of the following form:"
1100 msgstr ""
1101
1102 #. type: Plain text
1103 #: debian-trixie fedora-44 fedora-rawhide
1104 msgid ""
1105 "The I<flags> argument is a bit mask constructed by ORing together zero or "
1106 "more of B<AT_HANDLE_FID>, B<AT_EMPTY_PATH>, and B<AT_SYMLINK_FOLLOW>, "
1107 "described below."
1108 msgstr ""
1109
1110 #. type: Plain text
1111 #: debian-trixie fedora-44 fedora-rawhide
1112 msgid ""
1113 "Together, the I<pathname> and I<dirfd> arguments identify the file for which "
1114 "a handle is to be obtained. There are four distinct cases:"
1115 msgstr ""
1116
1117 #. type: Plain text
1118 #: debian-trixie fedora-44 fedora-rawhide
1119 msgid ""
1120 "If I<pathname> is a nonempty string containing an absolute pathname, then a "
1121 "handle is returned for the file referred to by that pathname. In this case, "
1122 "I<dirfd> is ignored."
1123 msgstr ""
1124
1125 #. type: Plain text
1126 #: debian-trixie fedora-44 fedora-rawhide
1127 msgid ""
1128 "If I<pathname> is a nonempty string containing a relative pathname and "
1129 "I<dirfd> has the special value B<AT_FDCWD>, then I<pathname> is interpreted "
1130 "relative to the current working directory of the caller, and a handle is "
1131 "returned for the file to which it refers."
1132 msgstr ""
1133
1134 #. type: Plain text
1135 #: debian-trixie fedora-44 fedora-rawhide
1136 msgid ""
1137 "If I<pathname> is a nonempty string containing a relative pathname and "
1138 "I<dirfd> is a file descriptor referring to a directory, then I<pathname> is "
1139 "interpreted relative to the directory referred to by I<dirfd>, and a handle "
1140 "is returned for the file to which it refers. (See B<openat>(2) for an "
1141 "explanation of why \"directory file descriptors\" are useful.)"
1142 msgstr ""
1143
1144 #. type: Plain text
1145 #: debian-trixie fedora-44 fedora-rawhide
1146 msgid ""
1147 "If I<pathname> is an empty string and I<flags> specifies the value "
1148 "B<AT_EMPTY_PATH>, then I<dirfd> can be an open file descriptor referring to "
1149 "any type of file, or B<AT_FDCWD>, meaning the current working directory, and "
1150 "a handle is returned for the file to which it refers."
1151 msgstr ""
1152
1153 #. type: Plain text
1154 #: debian-trixie fedora-44 fedora-rawhide
1155 msgid ""
1156 "The I<mount_id> argument returns an identifier for the filesystem mount that "
1157 "corresponds to I<pathname>. This corresponds to the first field in one of "
1158 "the records in I</proc/self/mountinfo>. Opening the pathname in the fifth "
1159 "field of that record yields a file descriptor for the mount point; that file "
1160 "descriptor can be used in a subsequent call to B<open_by_handle_at>(). "
1161 "I<mount_id> is returned both for a successful call and for a call that "
1162 "results in the error B<EOVERFLOW>."
1163 msgstr ""
1164
1165 #. type: Plain text
1166 #: debian-trixie fedora-44 fedora-rawhide
1167 msgid ""
1168 "By default, B<name_to_handle_at>() does not dereference I<pathname> if it "
1169 "is a symbolic link, and thus returns a handle for the link itself. If "
1170 "B<AT_SYMLINK_FOLLOW> is specified in I<flags>, I<pathname> is dereferenced "
1171 "if it is a symbolic link (so that the call returns a handle for the file "
1172 "referred to by the link)."
1173 msgstr ""
1174
1175 #. type: Plain text
1176 #: debian-trixie fedora-44 fedora-rawhide
1177 msgid ""
1178 "I<pathname>, I<mount_id>, or I<handle> points outside your accessible "
1179 "address space."
1180 msgstr ""
1181
1182 #. type: Plain text
1183 #: debian-trixie fedora-44 fedora-rawhide
1184 msgid "I<flags> includes an invalid bit value."
1185 msgstr ""
1186
1187 #. type: Plain text
1188 #: debian-trixie fedora-44 fedora-rawhide
1189 msgid ""
1190 "I<pathname> is an empty string, but B<AT_EMPTY_PATH> was not specified in "
1191 "I<flags>."
1192 msgstr ""
1193
1194 #. type: Plain text
1195 #: debian-trixie fedora-44 fedora-rawhide
1196 msgid ""
1197 "The file descriptor supplied in I<dirfd> does not refer to a directory, and "
1198 "it is not the case that both I<flags> includes B<AT_EMPTY_PATH> and "
1199 "I<pathname> is an empty string."
1200 msgstr ""
1201
1202 #. type: Plain text
1203 #: debian-trixie fedora-44 fedora-rawhide
1204 msgid ""
1205 "I<pathname> is relative but I<dirfd> is neither B<AT_FDCWD> nor a valid file "
1206 "descriptor."
1207 msgstr ""
1208
1209 #. type: Plain text
1210 #: debian-trixie fedora-44 fedora-rawhide
1211 msgid ""
1212 "The specified I<handle> is not valid for opening a file. This error will "
1213 "occur if, for example, the file has been deleted. This error can also occur "
1214 "if the I<handle> was acquired using the B<AT_HANDLE_FID> flag and the "
1215 "filesystem does not support B<open_by_handle_at>()."
1216 msgstr ""
1217
1218 #. commit bcda76524cd1fa32af748536f27f674a13e56700
1219 #. type: Plain text
1220 #: debian-trixie fedora-44 fedora-rawhide
1221 msgid ""
1222 "If I<pathname> refers to a symbolic link and I<flags> does not specify "
1223 "B<AT_SYMLINK_FOLLOW>, then B<name_to_handle_at>() returns a handle for the "
1224 "link (rather than the file to which it refers). The process receiving the "
1225 "handle can later perform operations on the symbolic link by converting the "
1226 "handle to a file descriptor using B<open_by_handle_at>() with the B<O_PATH> "
1227 "flag, and then passing the file descriptor as the I<dirfd> argument in "
1228 "system calls such as B<readlinkat>(2) and B<fchownat>(2)."
1229 msgstr ""
1230
1231 #. type: Plain text
1232 #: debian-trixie fedora-44 fedora-rawhide
1233 #, no-wrap
1234 msgid ""
1235 "$ B<echo \\[aq]Can you please think about it?\\[aq] E<gt> cecilia.txt>\n"
1236 "$ B<./t_name_to_handle_at cecilia.txt E<gt> fh>\n"
1237 "$ B<./t_open_by_handle_at E<lt> fh>\n"
1238 "open_by_handle_at: Operation not permitted\n"
1239 "$ B<sudo ./t_open_by_handle_at E<lt> fh> # Need CAP_SYS_ADMIN\n"
1240 "Read 31 bytes\n"
1241 "$ B<rm cecilia.txt>\n"
1242 msgstr ""
1243
1244 #. type: Plain text
1245 #: debian-trixie fedora-44 fedora-rawhide
1246 #, no-wrap
1247 msgid ""
1248 "$ B<stat --printf=\"%i\\[rs]n\" cecilia.txt> # Display inode number\n"
1249 "4072121\n"
1250 "$ B<rm cecilia.txt>\n"
1251 "$ B<echo \\[aq]Can you please think about it?\\[aq] E<gt> cecilia.txt>\n"
1252 "$ B<stat --printf=\"%i\\[rs]n\" cecilia.txt> # Check inode number\n"
1253 "4072121\n"
1254 "$ B<sudo ./t_open_by_handle_at E<lt> fh>\n"
1255 "open_by_handle_at: Stale NFS file handle\n"
1256 msgstr ""
1257
1258 #. type: Plain text
1259 #: debian-trixie fedora-44 fedora-rawhide
1260 #, no-wrap
1261 msgid ""
1262 "#define _GNU_SOURCE\n"
1263 "#include E<lt>err.hE<gt>\n"
1264 "#include E<lt>errno.hE<gt>\n"
1265 "#include E<lt>fcntl.hE<gt>\n"
1266 "#include E<lt>stdio.hE<gt>\n"
1267 "#include E<lt>stdlib.hE<gt>\n"
1268 "\\&\n"
1269 "int\n"
1270 "main(int argc, char *argv[])\n"
1271 "{\n"
1272 " int mount_id, fhsize, flags, dirfd;\n"
1273 " char *pathname;\n"
1274 " struct file_handle *fhp;\n"
1275 "\\&\n"
1276 " if (argc != 2) {\n"
1277 " fprintf(stderr, \"Usage: %s pathname\\[rs]n\", argv[0]);\n"
1278 " exit(EXIT_FAILURE);\n"
1279 " }\n"
1280 "\\&\n"
1281 " pathname = argv[1];\n"
1282 "\\&\n"
1283 " /* Allocate file_handle structure. */\n"
1284 "\\&\n"
1285 " fhsize = sizeof(*fhp);\n"
1286 " fhp = malloc(fhsize);\n"
1287 " if (fhp == NULL)\n"
1288 " err(EXIT_FAILURE, \"malloc\");\n"
1289 "\\&\n"
1290 " /* Make an initial call to name_to_handle_at() to discover\n"
1291 " the size required for file handle. */\n"
1292 "\\&\n"
1293 " dirfd = AT_FDCWD; /* For name_to_handle_at() calls */\n"
1294 " flags = 0; /* For name_to_handle_at() calls */\n"
1295 " fhp-E<gt>handle_bytes = 0;\n"
1296 " if (name_to_handle_at(dirfd, pathname, fhp,\n"
1297 " &mount_id, flags) != -1\n"
1298 " || errno != EOVERFLOW)\n"
1299 " {\n"
1300 " fprintf(stderr, \"Unexpected result from name_to_handle_at()\\[rs]n\");\n"
1301 " exit(EXIT_FAILURE);\n"
1302 " }\n"
1303 "\\&\n"
1304 " /* Reallocate file_handle structure with correct size. */\n"
1305 "\\&\n"
1306 " fhsize = sizeof(*fhp) + fhp-E<gt>handle_bytes;\n"
1307 " fhp = realloc(fhp, fhsize); /* Copies fhp-E<gt>handle_bytes */\n"
1308 " if (fhp == NULL)\n"
1309 " err(EXIT_FAILURE, \"realloc\");\n"
1310 "\\&\n"
1311 " /* Get file handle from pathname supplied on command line. */\n"
1312 "\\&\n"
1313 " if (name_to_handle_at(dirfd, pathname, fhp, &mount_id, flags) == -1)\n"
1314 " err(EXIT_FAILURE, \"name_to_handle_at\");\n"
1315 "\\&\n"
1316 " /* Write mount ID, file handle size, and file handle to stdout,\n"
1317 " for later reuse by t_open_by_handle_at.c. */\n"
1318 "\\&\n"
1319 " printf(\"%d\\[rs]n\", mount_id);\n"
1320 " printf(\"%u %d \", fhp-E<gt>handle_bytes, fhp-E<gt>handle_type);\n"
1321 " for (size_t j = 0; j E<lt> fhp-E<gt>handle_bytes; j++)\n"
1322 " printf(\" %02x\", fhp-E<gt>f_handle[j]);\n"
1323 " printf(\"\\[rs]n\");\n"
1324 "\\&\n"
1325 " exit(EXIT_SUCCESS);\n"
1326 "}\n"
1327 msgstr ""
1328
1329 #. type: Plain text
1330 #: debian-trixie fedora-44 fedora-rawhide
1331 #, no-wrap
1332 msgid ""
1333 "#define _GNU_SOURCE\n"
1334 "#include E<lt>err.hE<gt>\n"
1335 "#include E<lt>fcntl.hE<gt>\n"
1336 "#include E<lt>limits.hE<gt>\n"
1337 "#include E<lt>stdio.hE<gt>\n"
1338 "#include E<lt>stdlib.hE<gt>\n"
1339 "#include E<lt>string.hE<gt>\n"
1340 "#include E<lt>sys/types.hE<gt>\n"
1341 "#include E<lt>unistd.hE<gt>\n"
1342 "\\&\n"
1343 "/* Scan /proc/self/mountinfo to find the line whose mount ID matches\n"
1344 " \\[aq]mount_id\\[aq]. (An easier way to do this is to install and use the\n"
1345 " \\[aq]libmount\\[aq] library provided by the \\[aq]util-linux\\[aq] project.)\n"
1346 " Open the corresponding mount path and return the resulting file\n"
1347 " descriptor. */\n"
1348 "\\&\n"
1349 "static int\n"
1350 "open_mount_path_by_id(int mount_id)\n"
1351 "{\n"
1352 " int mi_mount_id, found;\n"
1353 " char mount_path[PATH_MAX];\n"
1354 " char *linep;\n"
1355 " FILE *fp;\n"
1356 " size_t lsize;\n"
1357 " ssize_t nread;\n"
1358 "\\&\n"
1359 " fp = fopen(\"/proc/self/mountinfo\", \"r\");\n"
1360 " if (fp == NULL)\n"
1361 " err(EXIT_FAILURE, \"fopen\");\n"
1362 "\\&\n"
1363 " found = 0;\n"
1364 " linep = NULL;\n"
1365 " while (!found) {\n"
1366 " nread = getline(&linep, &lsize, fp);\n"
1367 " if (nread == -1)\n"
1368 " break;\n"
1369 "\\&\n"
1370 " nread = sscanf(linep, \"%d %*d %*s %*s %s\",\n"
1371 " &mi_mount_id, mount_path);\n"
1372 " if (nread != 2) {\n"
1373 " fprintf(stderr, \"Bad sscanf()\\[rs]n\");\n"
1374 " exit(EXIT_FAILURE);\n"
1375 " }\n"
1376 "\\&\n"
1377 " if (mi_mount_id == mount_id)\n"
1378 " found = 1;\n"
1379 " }\n"
1380 " free(linep);\n"
1381 "\\&\n"
1382 " fclose(fp);\n"
1383 "\\&\n"
1384 " if (!found) {\n"
1385 " fprintf(stderr, \"Could not find mount point\\[rs]n\");\n"
1386 " exit(EXIT_FAILURE);\n"
1387 " }\n"
1388 "\\&\n"
1389 " return open(mount_path, O_RDONLY);\n"
1390 "}\n"
1391 "\\&\n"
1392 "int\n"
1393 "main(int argc, char *argv[])\n"
1394 "{\n"
1395 " int mount_id, fd, mount_fd, handle_bytes;\n"
1396 " char buf[1000];\n"
1397 "#define LINE_SIZE 100\n"
1398 " char line1[LINE_SIZE], line2[LINE_SIZE];\n"
1399 " char *nextp;\n"
1400 " ssize_t nread;\n"
1401 " struct file_handle *fhp;\n"
1402 "\\&\n"
1403 " if ((argc E<gt> 1 && strcmp(argv[1], \"--help\") == 0) || argc E<gt> 2) {\n"
1404 " fprintf(stderr, \"Usage: %s [mount-path]\\[rs]n\", argv[0]);\n"
1405 " exit(EXIT_FAILURE);\n"
1406 " }\n"
1407 "\\&\n"
1408 " /* Standard input contains mount ID and file handle information:\n"
1409 "\\&\n"
1410 " Line 1: E<lt>mount_idE<gt>\n"
1411 " Line 2: E<lt>handle_bytesE<gt> E<lt>handle_typeE<gt> E<lt>bytes of handle in hexE<gt>\n"
1412 " */\n"
1413 "\\&\n"
1414 " if (fgets(line1, sizeof(line1), stdin) == NULL ||\n"
1415 " fgets(line2, sizeof(line2), stdin) == NULL)\n"
1416 " {\n"
1417 " fprintf(stderr, \"Missing mount_id / file handle\\[rs]n\");\n"
1418 " exit(EXIT_FAILURE);\n"
1419 " }\n"
1420 "\\&\n"
1421 " mount_id = atoi(line1);\n"
1422 "\\&\n"
1423 " handle_bytes = strtoul(line2, &nextp, 0);\n"
1424 "\\&\n"
1425 " /* Given handle_bytes, we can now allocate file_handle structure. */\n"
1426 "\\&\n"
1427 " fhp = malloc(sizeof(*fhp) + handle_bytes);\n"
1428 " if (fhp == NULL)\n"
1429 " err(EXIT_FAILURE, \"malloc\");\n"
1430 "\\&\n"
1431 " fhp-E<gt>handle_bytes = handle_bytes;\n"
1432 "\\&\n"
1433 " fhp-E<gt>handle_type = strtoul(nextp, &nextp, 0);\n"
1434 "\\&\n"
1435 " for (size_t j = 0; j E<lt> fhp-E<gt>handle_bytes; j++)\n"
1436 " fhp-E<gt>f_handle[j] = strtoul(nextp, &nextp, 16);\n"
1437 "\\&\n"
1438 " /* Obtain file descriptor for mount point, either by opening\n"
1439 " the pathname specified on the command line, or by scanning\n"
1440 " /proc/self/mounts to find a mount that matches the \\[aq]mount_id\\[aq]\n"
1441 " that we received from stdin. */\n"
1442 "\\&\n"
1443 " if (argc E<gt> 1)\n"
1444 " mount_fd = open(argv[1], O_RDONLY);\n"
1445 " else\n"
1446 " mount_fd = open_mount_path_by_id(mount_id);\n"
1447 "\\&\n"
1448 " if (mount_fd == -1)\n"
1449 " err(EXIT_FAILURE, \"opening mount fd\");\n"
1450 "\\&\n"
1451 " /* Open file using handle and mount point. */\n"
1452 "\\&\n"
1453 " fd = open_by_handle_at(mount_fd, fhp, O_RDONLY);\n"
1454 " if (fd == -1)\n"
1455 " err(EXIT_FAILURE, \"open_by_handle_at\");\n"
1456 "\\&\n"
1457 " /* Try reading a few bytes from the file. */\n"
1458 "\\&\n"
1459 " nread = read(fd, buf, sizeof(buf));\n"
1460 " if (nread == -1)\n"
1461 " err(EXIT_FAILURE, \"read\");\n"
1462 "\\&\n"
1463 " printf(\"Read %zd bytes\\[rs]n\", nread);\n"
1464 "\\&\n"
1465 " exit(EXIT_SUCCESS);\n"
1466 "}\n"
1467 msgstr ""
1468
1469 #. type: Plain text
1470 #: debian-trixie fedora-44 fedora-rawhide
1471 msgid ""
1472 "The I<libblkid> and I<libmount> documentation in the latest I<util-linux> "
1473 "release at E<.UR https://www.kernel.org/pub/linux/utils/util-linux/> E<.UE>"
1474 msgstr ""
1475
1476 #. type: TH
1477 #: fedora-44 fedora-rawhide
1478 #, no-wrap
1479 msgid "2024-07-23"
1480 msgstr ""
1481
1482 #. type: TH
1483 #: fedora-44 fedora-rawhide
1484 #, no-wrap
1485 msgid "Linux man-pages 6.13"
1486 msgstr ""
1487
1488 #. type: TH
1489 #: mageia-cauldron
1490 #, no-wrap
1491 msgid "2026-02-08"
1492 msgstr ""
1493
1494 #. type: TH
1495 #: mageia-cauldron
1496 #, no-wrap
1497 msgid "Linux man-pages 6.17"
1498 msgstr ""
1499
1500 #. type: Plain text
1501 #: mageia-cauldron
1502 #, no-wrap
1503 msgid ""
1504 "#define _GNU_SOURCE\n"
1505 "#include E<lt>err.hE<gt>\n"
1506 "#include E<lt>fcntl.hE<gt>\n"
1507 "#include E<lt>limits.hE<gt>\n"
1508 "#include E<lt>stdio.hE<gt>\n"
1509 "#include E<lt>stdlib.hE<gt>\n"
1510 "#include E<lt>string.hE<gt>\n"
1511 "#include E<lt>sys/types.hE<gt>\n"
1512 "#include E<lt>unistd.hE<gt>\n"
1513 "\\&\n"
1514 "/* Scan /proc/self/mountinfo to find the line whose mount ID matches\n"
1515 " \\[aq]mount_id\\[aq]. (An easier way to do this is to install and use the\n"
1516 " \\[aq]libmount\\[aq] library provided by the \\[aq]util-linux\\[aq] project.)\n"
1517 " Open the corresponding mount path and return the resulting file\n"
1518 " descriptor. */\n"
1519 "\\&\n"
1520 "static int\n"
1521 "open_mount_path_by_id(int mount_id)\n"
1522 "{\n"
1523 " int mi_mount_id, found;\n"
1524 " char mount_path[PATH_MAX];\n"
1525 " char *linep;\n"
1526 " FILE *fp;\n"
1527 " size_t lsize;\n"
1528 " ssize_t nread;\n"
1529 "\\&\n"
1530 " fp = fopen(\"/proc/self/mountinfo\", \"r\");\n"
1531 " if (fp == NULL)\n"
1532 " err(EXIT_FAILURE, \"fopen\");\n"
1533 "\\&\n"
1534 " found = 0;\n"
1535 " linep = NULL;\n"
1536 " while (!found) {\n"
1537 " nread = getline(&linep, &lsize, fp);\n"
1538 " if (nread == -1)\n"
1539 " break;\n"
1540 "\\&\n"
1541 " nread = sscanf(linep, \"%d %*d %*s %*s %s\",\n"
1542 " &mi_mount_id, mount_path);\n"
1543 " if (nread != 2) {\n"
1544 " fprintf(stderr, \"Bad sscanf()\\[rs]n\");\n"
1545 " exit(EXIT_FAILURE);\n"
1546 " }\n"
1547 "\\&\n"
1548 " if (mi_mount_id == mount_id)\n"
1549 " found = 1;\n"
1550 " }\n"
1551 " free(linep);\n"
1552 "\\&\n"
1553 " fclose(fp);\n"
1554 "\\&\n"
1555 " if (!found) {\n"
1556 " fprintf(stderr, \"Could not find mount point\\[rs]n\");\n"
1557 " exit(EXIT_FAILURE);\n"
1558 " }\n"
1559 "\\&\n"
1560 " return open(mount_path, O_RDONLY);\n"
1561 "}\n"
1562 "\\&\n"
1563 "int\n"
1564 "main(int argc, char *argv[])\n"
1565 "{\n"
1566 " int mount_id, fd, mount_fd, handle_bytes;\n"
1567 " char buf[1000];\n"
1568 "#define LINE_SIZE 100\n"
1569 " char line1[LINE_SIZE], line2[LINE_SIZE];\n"
1570 " char *nextp;\n"
1571 " ssize_t nread;\n"
1572 " struct file_handle *fhp;\n"
1573 "\\&\n"
1574 " if ((argc E<gt> 1 && strcmp(argv[1], \"--help\") == 0) || argc E<gt> 2) {\n"
1575 " fprintf(stderr, \"Usage: %s [mount-path]\\[rs]n\", argv[0]);\n"
1576 " exit(EXIT_FAILURE);\n"
1577 " }\n"
1578 "\\&\n"
1579 " /* Standard input contains mount ID and file handle information:\n"
1580 "\\&\n"
1581 " Line 1: E<lt>mount_idE<gt>\n"
1582 " Line 2: E<lt>handle_bytesE<gt> E<lt>handle_typeE<gt> E<lt>bytes of handle in hexE<gt>\n"
1583 " */\n"
1584 "\\&\n"
1585 " if (fgets(line1, sizeof(line1), stdin) == NULL ||\n"
1586 " fgets(line2, sizeof(line2), stdin) == NULL)\n"
1587 " {\n"
1588 " fprintf(stderr, \"Missing mount_id / file handle\\[rs]n\");\n"
1589 " exit(EXIT_FAILURE);\n"
1590 " }\n"
1591 "\\&\n"
1592 " mount_id = atoi(line1);\n"
1593 "\\&\n"
1594 " handle_bytes = strtoul(line2, &nextp, 0);\n"
1595 "\\&\n"
1596 " /* Given handle_bytes, we can now allocate file_handle structure. */\n"
1597 "\\&\n"
1598 " fhp = malloc(sizeof(*fhp) + handle_bytes);\n"
1599 " if (fhp == NULL)\n"
1600 " err(EXIT_FAILURE, \"malloc\");\n"
1601 "\\&\n"
1602 " fhp-E<gt>handle_bytes = handle_bytes;\n"
1603 "\\&\n"
1604 " fhp-E<gt>handle_type = strtoul(nextp, &nextp, 0);\n"
1605 "\\&\n"
1606 " for (size_t j = 0; j E<lt> fhp-E<gt>handle_bytes; j++)\n"
1607 " fhp-E<gt>f_handle[j] = strtoul(nextp, &nextp, 16);\n"
1608 "\\&\n"
1609 " /* Obtain file descriptor for mount point, either by opening\n"
1610 " the pathname specified on the command line, or by scanning\n"
1611 " /proc/self/mounts to find a mount that matches the \\[aq]mount_id\\[aq]\n"
1612 " that we received from stdin. */\n"
1613 "\\&\n"
1614 " if (argc E<gt> 1)\n"
1615 " mount_fd = open(argv[1], O_RDONLY);\n"
1616 " else\n"
1617 " mount_fd = open_mount_path_by_id(mount_id);\n"
1618 "\\&\n"
1619 " if (mount_fd == -1)\n"
1620 " err(EXIT_FAILURE, \"opening mount fd\");\n"
1621 "\\&\n"
1622 " /* Open file using handle and mount point. */\n"
1623 "\\&\n"
1624 " fd = open_by_handle_at(mount_fd, fhp, O_RDONLY);\n"
1625 " if (fd == -1)\n"
1626 " err(EXIT_FAILURE, \"open_by_handle_at\");\n"
1627 "\\&\n"
1628 " /* Try reading a few bytes from the file. */\n"
1629 "\\&\n"
1630 " nread = read(fd, buf, sizeof(buf));\n"
1631 " if (nread == -1)\n"
1632 " err(EXIT_FAILURE, \"read\");\n"
1633 "\\&\n"
1634 " printf(\"Read %zd bytes\\[rs]n\", nread);\n"
1635 "\\&\n"
1636 " exit(EXIT_SUCCESS);\n"
1637 "}\n"
1638 msgstr ""
1639
1640 #. type: TH
1641 #: opensuse-leap-16-1 opensuse-tumbleweed
1642 #, no-wrap
1643 msgid "Linux man-pages (unreleased)"
1644 msgstr ""