| #
43b0384b |
| 01-Oct-2026 |
Maxim Sobolev <sobomax@FreeBSD.org> |
mountpoint(1): new utility, implemented as a stat(1) hardlink
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, unle
mountpoint(1): new utility, implemented as a stat(1) hardlink
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
show more ...
|
| #
21860bf9 |
| 11-Jun-2017 |
Enji Cooper <ngie@FreeBSD.org> |
Write up some basic tests for readlink(1)
The tests exercise -f (f_flag), -n (n_flag), and no arguments (basic).
MFC after: 1 month Sponsored by: Dell EMC Isilon
|
| #
5b812a14 |
| 13-Aug-2002 |
Doug Barton <dougb@FreeBSD.org> |
A cooperative effort...
1. Update the code to the latest from NetBSD, which includes: * A new command line option to suppress stat(2) errors * Output is now done via stdio * Fixes for bitwise OR'ing
A cooperative effort...
1. Update the code to the latest from NetBSD, which includes: * A new command line option to suppress stat(2) errors * Output is now done via stdio * Fixes for bitwise OR'ing of letters
2. Andrew from NetBSD merged in our own Johan's readlink patches.
3. Andrew also merged in some brucifications.
I made some small contributions to the header cleanup, and tried to generally improve the overall style(9)'ishness. I also documented the new -q option and added the *LINKS to the Makefile.
All responsibility for mistakes in merging the contributions from the above is mine.
Obtained from: Andrew Brown <atatat@NetBSD.org>, bde, johan
show more ...
|