pathname(7) — Linux manual page

NAME | DESCRIPTION | SEE ALSO | COLOPHON

pathname(7)          Miscellaneous Information Manual         pathname(7)

NAME         top

       pathname, filename - how pathnames are encoded and interpreted

DESCRIPTION         top

       Some system calls allow you to pass a pathname as a parameter.
       When writing code that deals with pathnames, there are kernel-
       space requirements that you must comply with, and user-space
       requirements that you should comply with.

       The kernel stores pathnames as C strings, that is, sequences of
       non-null bytes terminated by a null byte.  There are a few general
       rules that apply to all pathnames:

       •  The last byte in the sequence needs to be a null byte.

       •  Any other bytes in the sequence need to be non-null bytes.

       •  A 0x2F byte ('/') is always interpreted as a directory
          separator, and cannot be part of a filename.

       •  A pathname can be at most PATH_MAX bytes long (see
          limits.h(0p)).  A pathname that's longer than PATH_MAX bytes
          can be split into multiple smaller pathnames and opened
          piecewise using openat(2).

       •  A filename can be at most a certain number of bytes long.  The
          number is filesystem-specific (see _PC_NAME_MAX in
          fpathconf(3)).  For maximum portability, programs should be
          able to handle filenames that are as long as the relevant
          filesystems will allow.  For maximum portability, programs and
          users should limit the length of their own pathnames to
          NAME_MAX bytes (see limits.h(0p)).

       Some filesystems or APIs may apply further restrictions, such as
       requiring shorter filenames, or restricting the allowed bytes in a
       filename.

       For maximum interoperability, programs and users should also limit
       the characters that they use for their own pathnames to characters
       in the POSIX Portable Filename Character Set 
       ⟨https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/V1_chap03.html#tag_03_265⟩.

SEE ALSO         top

       limits.h(0p), open(2), fpathconf(3), path_resolution(7), mount(8)

COLOPHON         top

       This page is part of the man-pages (Linux kernel and C library
       user-space interface documentation) project.  Information about
       the project can be found at 
       ⟨https://www.kernel.org/doc/man-pages/⟩.  If you have a bug report
       for this manual page, see
       ⟨https://git.kernel.org/pub/scm/docs/man-pages/man-pages.git/tree/CONTRIBUTING⟩.
       This page was obtained from the tarball man-pages-6.15.tar.gz
       fetched from
       ⟨https://mirrors.edge.kernel.org/pub/linux/docs/man-pages/⟩ on
       2025-08-11.  If you discover any rendering problems in this HTML
       version of the page, or you believe there is a better or more up-
       to-date source for the page, or you have corrections or
       improvements to the information in this COLOPHON (which is not
       part of the original manual page), send a mail to
       man-pages@man7.org

Linux man-pages 6.15            2025-05-17                    pathname(7)