History log of /linux/samples/vfs/mountinfo.c (Results 1 – 5 of 5)
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 100ceb48 20-Jan-2025 Linus Torvalds <torvalds@linux-foundation.org>

Merge tag 'vfs-6.14-rc1.mount.v2' of git://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs

Pull vfs mount updates from Christian Brauner:

- Add a mountinfo program to demonstrate statmount()/listm

Merge tag 'vfs-6.14-rc1.mount.v2' of git://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs

Pull vfs mount updates from Christian Brauner:

- Add a mountinfo program to demonstrate statmount()/listmount()

Add a new "mountinfo" sample userland program that demonstrates how
to use statmount() and listmount() to get at the same info that
/proc/pid/mountinfo provides

- Remove pointless nospec.h include

- Prepend statmount.mnt_opts string with security_sb_mnt_opts()

Currently these mount options aren't accessible via statmount()

- Add new mount namespaces to mount namespace rbtree outside of the
namespace semaphore

- Lockless mount namespace lookup

Currently we take the read lock when looking for a mount namespace to
list mounts in. We can make this lockless. The simple search case can
just use a sequence counter to detect concurrent changes to the
rbtree

For walking the list of mount namespaces sequentially via nsfs we
keep a separate rcu list as rb_prev() and rb_next() aren't usable
safely with rcu. Currently there is no primitive for retrieving the
previous list member. To do this we need a new deletion primitive
that doesn't poison the prev pointer and a corresponding retrieval
helper

Since creating mount namespaces is a relatively rare event compared
with querying mounts in a foreign mount namespace this is worth it.
Once libmount and systemd pick up this mechanism to list mounts in
foreign mount namespaces this will be used very frequently

- Add extended selftests for lockless mount namespace iteration

- Add a sample program to list all mounts on the system, i.e., in
all mount namespaces

- Improve mount namespace iteration performance

Make finding the last or first mount to start iterating the mount
namespace from an O(1) operation and add selftests for iterating the
mount table starting from the first and last mount

- Use an xarray for the old mount id

While the ida does use the xarray internally we can use it explicitly
which allows us to increment the unique mount id under the xa lock.
This allows us to remove the atomic as we're now allocating both ids
in one go

- Use a shared header for vfs sample programs

- Fix build warnings for new sample program to list all mounts

* tag 'vfs-6.14-rc1.mount.v2' of git://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs:
samples/vfs: fix build warnings
samples/vfs: use shared header
samples/vfs/mountinfo: Use __u64 instead of uint64_t
fs: remove useless lockdep assertion
fs: use xarray for old mount id
selftests: add listmount() iteration tests
fs: cache first and last mount
samples: add test-list-all-mounts
selftests: remove unneeded include
selftests: add tests for mntns iteration
seltests: move nsfs into filesystems subfolder
fs: simplify rwlock to spinlock
fs: lockless mntns lookup for nsfs
rculist: add list_bidir_{del,prev}_rcu()
fs: lockless mntns rbtree lookup
fs: add mount namespace to rbtree late
fs: prepend statmount.mnt_opts string with security_sb_mnt_opts()
mount: remove inlude/nospec.h include
samples: add a mountinfo program to demonstrate statmount()/listmount()

show more ...


# f9d94f78 20-Jan-2025 Christian Brauner <brauner@kernel.org>

samples/vfs: use shared header

Share some infrastructure between sample programs and fix a build
failure that was reported.

Reported-by: Sasha Levin <sashal@kernel.org>
Link: https://lore.kernel.or

samples/vfs: use shared header

Share some infrastructure between sample programs and fix a build
failure that was reported.

Reported-by: Sasha Levin <sashal@kernel.org>
Link: https://lore.kernel.org/r/Z42UkSXx0MS9qZ9w@lappy
Link: https://qa-reports.linaro.org/lkft/sashal-linus-next/build/v6.13-rc7-511-g109a8e0fa9d6/testrun/26809210/suite/build/test/gcc-8-allyesconfig/log
Signed-off-by: Christian Brauner <brauner@kernel.org>

show more ...


Revision tags: v6.13, v6.13-rc7
# f79e6eb8 06-Jan-2025 Geert Uytterhoeven <geert+renesas@glider.be>

samples/vfs/mountinfo: Use __u64 instead of uint64_t

On 32-bit (e.g. arm32, m68k):

samples/vfs/mountinfo.c: In function ‘dump_mountinfo’:
samples/vfs/mountinfo.c:145:29: warning: format ‘%l

samples/vfs/mountinfo: Use __u64 instead of uint64_t

On 32-bit (e.g. arm32, m68k):

samples/vfs/mountinfo.c: In function ‘dump_mountinfo’:
samples/vfs/mountinfo.c:145:29: warning: format ‘%lx’ expects argument of type ‘long unsigned int’, but argument 2 has type ‘uint64_t’ {aka ‘long long unsigned int’} [-Wformat=]
145 | printf("0x%lx 0x%lx 0x%llx ", mnt_ns_id, mnt_id, buf->mnt_parent_id);
| ~~^ ~~~~~~~~~
| | |
| long unsigned int uint64_t {aka long long unsigned int}
| %llx
samples/vfs/mountinfo.c:145:35: warning: format ‘%lx’ expects argument of type ‘long unsigned int’, but argument 3 has type ‘uint64_t’ {aka ‘long long unsigned int’} [-Wformat=]
145 | printf("0x%lx 0x%lx 0x%llx ", mnt_ns_id, mnt_id, buf->mnt_parent_id);
| ~~^ ~~~~~~
| | |
| long unsigned int uint64_t {aka long long unsigned int}
| %llx

Just using "%llx" instead of "%lx" is not sufficient, as uint64_t is
"long unsigned int" on some 64-bit platforms like arm64. Hence also
replace "uint64_t" by "__u64", which matches what most other samples
are already using.

Fixes: d95e49bf8bcdc7c1 ("samples: add a mountinfo program to demonstrate statmount()/listmount()")
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Link: https://lore.kernel.org/r/20250106134802.1019911-1-geert+renesas@glider.be
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Christian Brauner <brauner@kernel.org>

show more ...


Revision tags: v6.13-rc6, v6.13-rc5, v6.13-rc4
# bd320736 22-Dec-2024 Christian Brauner <brauner@kernel.org>

Merge patch series "fs: listmount()/statmount() fix and sample program"

Jeff Layton <jlayton@kernel.org> says:

We had some recent queries internally asking how to use the new
statmount() and listmo

Merge patch series "fs: listmount()/statmount() fix and sample program"

Jeff Layton <jlayton@kernel.org> says:

We had some recent queries internally asking how to use the new
statmount() and listmount() interfaces. I was doing some other work in
this area, so I whipped up this tool.

My hope is that this will represent something of a "rosetta stone" for
how to translate between mountinfo and statmount(), and an example for
other people looking to use the new interfaces.

It may also be possible to use this as the basis for a listmount() and
statmount() testcase. We can call this program, and compare its output
to the mountinfo file.

The second patch adds security mount options to the existing mnt_opts in
the statmount() interface, which I think is the final missing piece
here. The alternative to doing that would be to add a new string field
for that, but I'm not sure that's worthwhile.

* patches from https://lore.kernel.org/r/20241115-statmount-v2-0-cd29aeff9cbb@kernel.org:
fs: prepend statmount.mnt_opts string with security_sb_mnt_opts()
samples: add a mountinfo program to demonstrate statmount()/listmount()

Link: https://lore.kernel.org/r/20241115-statmount-v2-0-cd29aeff9cbb@kernel.org
Signed-off-by: Christian Brauner <brauner@kernel.org>

show more ...


Revision tags: v6.13-rc3, v6.13-rc2, v6.13-rc1, v6.12
# c6640d46 15-Nov-2024 Jeff Layton <jlayton@kernel.org>

samples: add a mountinfo program to demonstrate statmount()/listmount()

Add a new "mountinfo" sample userland program that demonstrates how to
use statmount() and listmount() to get at the same info

samples: add a mountinfo program to demonstrate statmount()/listmount()

Add a new "mountinfo" sample userland program that demonstrates how to
use statmount() and listmount() to get at the same info that
/proc/pid/mountinfo provides.

The output of the program tries to mimic the mountinfo procfile
contents. With the -p flag, it can be pointed at an arbitrary pid to
print out info about its mount namespace. With the -r flag it will
attempt to walk all of the namespaces under the pid's mount namespace
and dump out mount info from all of them.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
Link: https://lore.kernel.org/r/20241115-statmount-v2-1-cd29aeff9cbb@kernel.org
Signed-off-by: Christian Brauner <brauner@kernel.org>

show more ...