mirror of
https://github.com/torvalds/linux.git
synced 2026-04-22 16:53:59 -04:00
selftests: add a test for the foreign mnt ns extensions
This tests both statmount and listmount to make sure they work with the extensions that allow us to specify a mount ns to enter in order to find the mount entries. Signed-off-by: Josef Bacik <josef@toxicpanda.com> Link: https://lore.kernel.org/r/2d1a35bc9ab94b4656c056c420f25e429e7eb0b1.1719243756.git.josef@toxicpanda.com Signed-off-by: Christian Brauner <brauner@kernel.org>
This commit is contained in:
committed by
Christian Brauner
parent
e8e43a1fcc
commit
d896f71ce1
46
tools/testing/selftests/filesystems/statmount/statmount.h
Normal file
46
tools/testing/selftests/filesystems/statmount/statmount.h
Normal file
@@ -0,0 +1,46 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0 */
|
||||
|
||||
#ifndef __STATMOUNT_H
|
||||
#define __STATMOUNT_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <linux/mount.h>
|
||||
#include <asm/unistd.h>
|
||||
|
||||
static inline int statmount(uint64_t mnt_id, uint64_t mnt_ns_id, uint64_t mask,
|
||||
struct statmount *buf, size_t bufsize,
|
||||
unsigned int flags)
|
||||
{
|
||||
struct mnt_id_req req = {
|
||||
.size = MNT_ID_REQ_SIZE_VER0,
|
||||
.mnt_id = mnt_id,
|
||||
.param = mask,
|
||||
};
|
||||
|
||||
if (mnt_ns_id) {
|
||||
req.size = MNT_ID_REQ_SIZE_VER1;
|
||||
req.mnt_ns_id = mnt_ns_id;
|
||||
}
|
||||
|
||||
return syscall(__NR_statmount, &req, buf, bufsize, flags);
|
||||
}
|
||||
|
||||
static ssize_t listmount(uint64_t mnt_id, uint64_t mnt_ns_id,
|
||||
uint64_t last_mnt_id, uint64_t list[], size_t num,
|
||||
unsigned int flags)
|
||||
{
|
||||
struct mnt_id_req req = {
|
||||
.size = MNT_ID_REQ_SIZE_VER0,
|
||||
.mnt_id = mnt_id,
|
||||
.param = last_mnt_id,
|
||||
};
|
||||
|
||||
if (mnt_ns_id) {
|
||||
req.size = MNT_ID_REQ_SIZE_VER1;
|
||||
req.mnt_ns_id = mnt_ns_id;
|
||||
}
|
||||
|
||||
return syscall(__NR_listmount, &req, list, num, flags);
|
||||
}
|
||||
|
||||
#endif /* __STATMOUNT_H */
|
||||
Reference in New Issue
Block a user