diff options
author | Lennart Poettering <lennart@poettering.net> | 2023-03-07 11:19:35 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2023-03-09 21:56:42 +0100 |
commit | 117e7034470251a7da4061c83cb49df32c0defe0 (patch) | |
tree | 21791eea4fdbbe73e1bee7dec824a52d5c0fd447 /src/test/test-mountpoint-util.c | |
parent | gpt-auto-generator: port to partition_pick_mount_options() too (diff) | |
download | systemd-117e7034470251a7da4061c83cb49df32c0defe0.tar.xz systemd-117e7034470251a7da4061c83cb49df32c0defe0.zip |
mountpoint-util: generalize mount_option_supported()
Diffstat (limited to 'src/test/test-mountpoint-util.c')
-rw-r--r-- | src/test/test-mountpoint-util.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/test/test-mountpoint-util.c b/src/test/test-mountpoint-util.c index 5df853a1d9..5feda55641 100644 --- a/src/test/test-mountpoint-util.c +++ b/src/test/test-mountpoint-util.c @@ -325,6 +325,30 @@ TEST(ms_nosymfollow_supported) { log_info("MS_NOSYMFOLLOW supported: %s", yes_no(ms_nosymfollow_supported())); } +TEST(mount_option_supported) { + int r; + + r = mount_option_supported("tmpfs", "size", "64M"); + log_info("tmpfs supports size=64M: %s (%i)", r < 0 ? "dont know" : yes_no(r), r); + assert_se(r > 0 || (r < 0 && ERRNO_IS_PRIVILEGE(r))); + + r = mount_option_supported("ext4", "discard", NULL); + log_info("ext4 supports discard: %s (%i)", r < 0 ? "dont know" : yes_no(r), r); + assert_se(r > 0 || r == -EAGAIN || (r < 0 && ERRNO_IS_PRIVILEGE(r))); + + r = mount_option_supported("tmpfs", "idontexist", "64M"); + log_info("tmpfs supports idontexist: %s (%i)", r < 0 ? "dont know" : yes_no(r), r); + assert_se(r == 0 || (r < 0 && ERRNO_IS_PRIVILEGE(r))); + + r = mount_option_supported("tmpfs", "ialsodontexist", NULL); + log_info("tmpfs supports ialsodontexist: %s (%i)", r < 0 ? "dont know" : yes_no(r), r); + assert_se(r == 0 || (r < 0 && ERRNO_IS_PRIVILEGE(r))); + + r = mount_option_supported("proc", "hidepid", "1"); + log_info("proc supports hidepid=1: %s (%i)", r < 0 ? "dont know" : yes_no(r), r); + assert_se(r >= 0 || (r < 0 && ERRNO_IS_PRIVILEGE(r))); +} + static int intro(void) { /* let's move into our own mount namespace with all propagation from the host turned off, so * that /proc/self/mountinfo is static and constant for the whole time our test runs. */ |