]> git.ipfire.org Git - thirdparty/util-linux.git/commit
mountpoint: add --show option to print mountpoint path
authorKarel Zak <kzak@redhat.com>
Wed, 19 Nov 2025 12:32:25 +0000 (13:32 +0100)
committerKarel Zak <kzak@redhat.com>
Thu, 20 Nov 2025 10:29:22 +0000 (11:29 +0100)
commitf7facbb928a908ff4453891e45f124669f8318f1
tree75f8c923c8f19460463e57560d73bc3957d9dbd7
parent5fc8401d09d791d132badd3029426407a8733dea
mountpoint: add --show option to print mountpoint path

Add a new --show option that prints the actual mountpoint path for
a given directory or file. This is useful for:
- Resolving any path to its containing mountpoint
- Finding the canonical mountpoint path when symlinks are involved
- Determining the mountpoint from paths within filesystems

The option requires kernel support for statmount(2) (Linux 6.8+).
On older kernels without statmount support, the option fails with
an error message, as the /proc/self/mountinfo fallback cannot
resolve arbitrary paths to their containing mountpoint.

Example usage:
  $ mountpoint --show /
  /
  $ mountpoint --show /home/user/file.txt
  /home

The --show option always returns EXIT_SUCCESS (0) when it successfully
finds the mountpoint, regardless of whether the given path itself is
a mountpoint or not.

Addresses: https://github.com/util-linux/util-linux/issues/3806
Signed-off-by: Karel Zak <kzak@redhat.com>
sys-utils/mountpoint.1.adoc
sys-utils/mountpoint.c