diff options
| author | Maxim Sobolev <sobomax@FreeBSD.org> | 2026-10-01 21:25:37 +0000 |
|---|---|---|
| committer | Maxim Sobolev <sobomax@FreeBSD.org> | 2026-10-01 21:25:37 +0000 |
| commit | 43b0384bc7e87df5bd164ce833617e68824f4828 (patch) | |
| tree | 1ed521121892050b53aa691dd4f74ed294893d86 /sys/modules/mpr/(public-mirror) | |
| parent | 5f275e547814db5944ff1ca746c31447a0896e1e (diff) | |
Add mountpoint(1), a simple utility to tell whether the file pointed
to by the argument is a mount point. It prints whether it is, unless
-q is given, and exits 0 if it is, 1 if it is not, and 2 on error.
The answer comes from the kernel with a single stat(2): the root vnode
of a mounted file system is reported with SFBSD_MNTPOINT in
st_bsdflags. Unlike comparing realpath(3) of the argument with that
of statfs(2)'s f_mntonname, this works for arbitrarily deep
hierarchies, and after chroot(2) or inside a jail. A chroot or jail
root is reported as a mount point only if it is one.
The argument does not have to be a directory: file systems such as
nullfs(5) can be mounted over regular files and sockets, and stat(2)
reports those mount points as well.
Since all that is needed is one stat(2) call, make mountpoint a
hardlink to stat(1), the same way readlink(1) is, and document it in
stat.1.
Add ATF tests, including chroot(8) and jail(8) roots that are and are
not mount points, nullfs roots, file systems mounted inside the root,
both from the host and from within the jail, and a nullfs mount of a
file over a file.
Suggested by: kib
Differential revision: https://reviews.freebsd.org/D59906
Sponsored by: Sippy Software, Inc.
MFC after: 2 weeks
Diffstat (limited to 'sys/modules/mpr/(public-mirror)')
0 files changed, 0 insertions, 0 deletions
