public inbox for linux-man@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] man/man7/path-format.7: Add file documenting format of pathnames
@ 2025-01-13 21:32 Jason Yundt
  2025-01-14  0:20 ` Alejandro Colomar
                   ` (8 more replies)
  0 siblings, 9 replies; 38+ messages in thread
From: Jason Yundt @ 2025-01-13 21:32 UTC (permalink / raw)
  To: Alejandro Colomar; +Cc: Jason Yundt, linux-man

The goal of this new manual page is to help people create programs that
do the right thing even in the face of unusual paths.  The information
that I used to create this new manual page came from this Unix & Linux
Stack Exchange answer [1] and from this Libc-help mailing list post [2].

[1]: <https://unix.stackexchange.com/a/39179/316181>
[2]: <https://sourceware.org/pipermail/libc-help/2024-August/006737.html>

Signed-off-by: Jason Yundt <jason@jasonyundt.email>
---
 man/man7/path-format.7 | 41 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)
 create mode 100644 man/man7/path-format.7

diff --git a/man/man7/path-format.7 b/man/man7/path-format.7
new file mode 100644
index 000000000..c3c01cbf5
--- /dev/null
+++ b/man/man7/path-format.7
@@ -0,0 +1,41 @@
+.\" Copyright (C) 2025 Jason Yundt (jason@jasonyundt.email)
+.\"
+.\" SPDX-License-Identifier: Linux-man-pages-copyleft
+.\"
+.TH PATH-FORMAT 7 (date) "Linux man-pages (unreleased)"
+.SH NAME
+path-format \- how pathnames are encoded and interpreted
+.SH DESCRIPTION
+Some system calls allow you to pass a pathname as a parameter.
+When writing code that deals with paths,
+there are kernel space requirements that you must comply with
+and userspace requirements that you should comply with.
+.P
+The kernel stores paths as null-terminated byte sequences.
+As far as the kernel is concerned, there are only three rules for paths:
+.IP \[bu]
+The last byte in the sequence needs to be a null.
+.IP \[bu]
+Any other bytes in the sequence need to not be null bytes.
+.IP \[bu]
+A 0x2F byte is always interpreted as a directory separator (/).
+.P
+This means that programs can technically do weird things
+like create paths using random character encodings
+or create paths without using any character encoding at all.
+Filesystems may impose additional restrictions on paths, though.
+For example, if you want to store a file on an ext4 filesystem,
+then its filename can’t be longer than 255 bytes.
+.P
+Userspace treats paths differently.
+Userspace applications typically expect paths to use
+a consistent character encoding.
+For maximum interoperability, programs should use
+.BR nl_langinfo (3)
+to determine the current locale’s codeset.
+Paths should be encoded and decoded using the current locale’s codeset
+in order to help prevent mojibake.
+.SH SEE ALSO
+.BR open (2),
+.BR nl_langinfo (3),
+.BR path_resolution (7)
-- 
2.47.0


^ permalink raw reply related	[flat|nested] 38+ messages in thread

end of thread, other threads:[~2025-01-23 23:51 UTC | newest]

Thread overview: 38+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-13 21:32 [PATCH] man/man7/path-format.7: Add file documenting format of pathnames Jason Yundt
2025-01-14  0:20 ` Alejandro Colomar
2025-01-14 12:54 ` [PATCH v2] " Jason Yundt
2025-01-14 13:14   ` Alejandro Colomar
2025-01-14 21:00     ` Jason Yundt
2025-01-14 23:06       ` Alejandro Colomar
2025-01-15 16:21         ` Jason Yundt
2025-01-15 16:47           ` Alejandro Colomar
2025-01-15 17:44             ` G. Branden Robinson
2025-01-15  9:01   ` Florian Weimer
2025-01-14 21:01 ` [PATCH v3] man/man7/path_format.7: " Jason Yundt
2025-01-15 16:20 ` [PATCH v4] man/man7/pathname.7: " Jason Yundt
2025-01-15 17:12   ` Florian Weimer
2025-01-15 17:20   ` Alejandro Colomar
2025-01-15 18:37     ` A modest proposal regarding pathnames (was: " G. Branden Robinson
2025-01-15 19:25       ` Alejandro Colomar
2025-01-15 19:47         ` Alejandro Colomar
2025-01-17 13:02 ` [PATCH v5] " Jason Yundt
2025-01-17 14:14   ` Alejandro Colomar
2025-01-18  0:01     ` Jason Yundt
2025-01-18  0:23       ` Alejandro Colomar
2025-01-19 13:17         ` Jason Yundt
2025-01-19 15:24           ` Alejandro Colomar
2025-01-20  8:20             ` Florian Weimer
2025-01-20 11:14               ` Alejandro Colomar
2025-01-20 13:17                 ` Jason Yundt
2025-01-20 13:25                   ` Alejandro Colomar
2025-01-17 23:59 ` [PATCH v6] " Jason Yundt
2025-01-20 16:24 ` [PATCH v8] " Jason Yundt
2025-01-20 16:36   ` Alejandro Colomar
2025-01-20 19:06 ` [PATCH v9] " Jason Yundt
2025-01-20 22:26   ` Alejandro Colomar
2025-01-21  0:26     ` C code style for Linux man-pages examples (was: [PATCH v9] man/man7/pathname.7: Add file documenting format of pathnames) G. Branden Robinson
2025-01-21  1:05       ` Alejandro Colomar
2025-01-21 13:39       ` Jason Yundt
2025-01-21 14:00         ` Alejandro Colomar
2025-01-21 13:35 ` [PATCH v10] man/man7/pathname.7: Add file documenting format of pathnames Jason Yundt
2025-01-23 23:51   ` Alejandro Colomar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox