-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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>
- Loading branch information
Josef Bacik
authored and
Christian Brauner
committed
Jun 28, 2024
1 parent
e8e43a1
commit d896f71
Showing
4 changed files
with
424 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
# SPDX-License-Identifier: GPL-2.0-or-later | ||
|
||
CFLAGS += -Wall -O2 -g $(KHDR_INCLUDES) | ||
TEST_GEN_PROGS := statmount_test | ||
TEST_GEN_PROGS := statmount_test statmount_test_ns | ||
|
||
include ../../lib.mk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.