[CRIU] [PATCH] test: check read-only bind-mounts
Tycho Andersen
tycho.andersen at canonical.com
Thu Mar 26 07:50:10 PDT 2015
On Wed, Mar 25, 2015 at 07:59:30PM +0300, Andrey Vagin wrote:
> Here is a real example how it's used.
>
> Cc: Tycho Andersen <tycho.andersen at canonical.com>
Not sure what the procedure is here in terms of merging, as this test
does currently fail as Andrey said it would.
Tested-by: Tycho Andersen <tycho.andersen at canonical.com>
> Signed-off-by: Andrey Vagin <avagin at openvz.org>
> ---
> test/zdtm.sh | 1 +
> test/zdtm/live/static/Makefile | 1 +
> test/zdtm/live/static/mntns_rw_ro_rw.c | 46 ++++++++++++++++++++++++++++++++++
> 3 files changed, 48 insertions(+)
> create mode 100644 test/zdtm/live/static/mntns_rw_ro_rw.c
>
> diff --git a/test/zdtm.sh b/test/zdtm.sh
> index 577e456..1d47487 100755
> --- a/test/zdtm.sh
> +++ b/test/zdtm.sh
> @@ -321,6 +321,7 @@ mntns_link_ghost
> mntns_shared_bind
> mntns_shared_bind02
> mntns_root_bind
> +mntns_rw_ro_rw
> sockets00
> cow01
> "
> diff --git a/test/zdtm/live/static/Makefile b/test/zdtm/live/static/Makefile
> index 418e138..32a3fa0 100644
> --- a/test/zdtm/live/static/Makefile
> +++ b/test/zdtm/live/static/Makefile
> @@ -113,6 +113,7 @@ TST_NOFILE = \
> stopped \
> rtc \
> clean_mntns \
> + mntns_rw_ro_rw \
> dumpable01 \
> dumpable02 \
> remap_dead_pid \
> diff --git a/test/zdtm/live/static/mntns_rw_ro_rw.c b/test/zdtm/live/static/mntns_rw_ro_rw.c
> new file mode 100644
> index 0000000..14a134c
> --- /dev/null
> +++ b/test/zdtm/live/static/mntns_rw_ro_rw.c
> @@ -0,0 +1,46 @@
> +#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 at 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;
> +}
> --
> 2.1.0
>
More information about the CRIU
mailing list