Debian Codegraph @

upstream/fedora-44/man7/pathname.7

raw
1 .\" Copyright 2025, Jason Yundt <[email protected]>
2 .\"
3 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
4 .\"
5 .TH pathname 7 2025-01-28 "Linux man-pages 6.13"
6 .SH NAME
7 pathname,
8 filename
9 \-
10 how pathnames are encoded and interpreted
11 .SH DESCRIPTION
12 Some system calls allow you to pass a pathname as a parameter.
13 When writing code that deals with pathnames,
14 there are kernel-space requirements that you must comply with,
15 and user-space requirements that you should comply with.
16 .P
17 The kernel stores pathnames as C strings,
18 that is,
19 sequences of non-null bytes terminated by a null byte.
20 There are a few general rules that apply to all pathnames:
21 .IP \[bu] 3
22 The last byte in the sequence needs to be a null byte.
23 .IP \[bu]
24 Any other bytes in the sequence need to be non-null bytes.
25 .IP \[bu]
26 A 0x2F byte
27 .RI ( \[aq]/\[aq] )
28 is always interpreted as a directory separator,
29 and cannot be part of a filename.
30 .IP \[bu]
31 A pathname can be at most
32 .B PATH_MAX
33 bytes long
34 (see
35 .BR limits.h (0p)).
36 A pathname that's longer than
37 .B PATH_MAX
38 bytes
39 can be split into multiple smaller pathnames
40 and opened piecewise using
41 .BR openat (2).
42 .IP \[bu]
43 A filename can be at most a certain number of bytes long.
44 The number is filesystem-specific
45 (see
46 .B _PC_NAME_MAX
47 in
48 .BR fpathconf (3)).
49 For maximum portability,
50 programs should be able to
51 handle filenames that are as long as the relevant filesystems will allow.
52 For maximum portability,
53 programs and users should
54 limit the length of their own pathnames to
55 .B NAME_MAX
56 bytes
57 (see
58 .BR limits.h (0p)).
59 .P
60 Some filesystems or APIs may apply further restrictions,
61 such as requiring shorter filenames,
62 or restricting the allowed bytes in a filename.
63 .P
64 For maximum interoperability,
65 programs and users should also
66 limit the characters that they use for their own pathnames to
67 characters in the POSIX
68 .UR https://pubs.opengroup.org/\:onlinepubs/\:9799919799/\:basedefs/\:V1_chap03.html#tag_03_265
69 Portable Filename Character Set
70 .UE .
71 .SH SEE ALSO
72 .BR limits.h (0p),
73 .BR open (2),
74 .BR fpathconf (3),
75 .BR path_resolution (7),
76 .BR mount (8)