Commit 019ab4b7 authored by Andrey Vagin's avatar Andrey Vagin Committed by Pavel Emelyanov

test: check read-only bind-mounts

Here is a real example how it's used.

Cc:  Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: 's avatarAndrey Vagin <avagin@openvz.org>
Tested-by: 's avatarTycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 57db932a
...@@ -323,6 +323,7 @@ mntns_link_ghost ...@@ -323,6 +323,7 @@ mntns_link_ghost
mntns_shared_bind mntns_shared_bind
mntns_shared_bind02 mntns_shared_bind02
mntns_root_bind mntns_root_bind
mntns_rw_ro_rw
sockets00 sockets00
cow01 cow01
" "
......
...@@ -114,6 +114,7 @@ TST_NOFILE = \ ...@@ -114,6 +114,7 @@ TST_NOFILE = \
stopped \ stopped \
rtc \ rtc \
clean_mntns \ clean_mntns \
mntns_rw_ro_rw \
dumpable01 \ dumpable01 \
dumpable02 \ dumpable02 \
remap_dead_pid \ remap_dead_pid \
......
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/mount.h>
#include <fcntl.h>
#include <stdio.h>
#include <unistd.h>
#include "zdtmtst.h"
const char *test_doc = "Test read-only bind mounts";
const char *test_author = "Andrey Vagin <xemul@parallels.com>";
int main(int argc, char **argv)
{
test_init(argc, argv);
if (mount("/proc/sys/", "/proc/sys", NULL, MS_BIND, NULL)) {
err("Unable to bind-mount /proc/sys");
return 1;
}
if (mount("/proc/sys/net", "/proc/sys/net", NULL, MS_BIND, NULL)) {
err("Unable to bind-mount /proc/sys/net");
return 1;
}
if (mount("/proc/sys/", "/proc/sys", NULL, MS_RDONLY|MS_BIND|MS_REMOUNT, NULL)) {
err("Unable to remount /proc/sys");
return 1;
}
test_daemon();
test_waitsig();
if (access("/proc/sys/net/unix/max_dgram_qlen", W_OK)) {
fail("Unable to access /proc/sys/net/core/wmem_max");
return 1;
}
if (access("/proc/sys/kernel/pid_max", W_OK) != -1 || errno != EROFS) {
fail("Unable to access /proc/sys/kernel/pid_max");
return 1;
}
pass();
return 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment