From c5d238ef6636df9f4f651487e9fbaf79408ebe4e Mon Sep 17 00:00:00 2001 From: Andrey Vagin Date: Fri, 29 Aug 2014 15:23:17 +0400 Subject: [PATCH] zdtm/fanotify00: use /tmp instead of / Usually /tmp is a mount point. Recently we found a bug in criu, when it restore mount fanotify on "./" instead of "/". The test didn't find it, because they are pointed on the same mount point. Signed-off-by: Andrey Vagin Signed-off-by: Pavel Emelyanov --- test/.gitignore | 1 + test/Makefile | 1 + test/zdtm/live/static/fanotify00.c | 19 +++++++++++++++---- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/test/.gitignore b/test/.gitignore index 1a6f6d251..d53c95961 100644 --- a/test/.gitignore +++ b/test/.gitignore @@ -3,5 +3,6 @@ /bin /dev /dump +/tmp /*.log /zdtm_ct diff --git a/test/Makefile b/test/Makefile index 2812e33ae..2c15039cd 100644 --- a/test/Makefile +++ b/test/Makefile @@ -36,6 +36,7 @@ clean: $(Q) $(RM) -r ./lib/ $(Q) $(RM) -r ./lib64/ $(Q) $(RM) -r ./dump/ + $(Q) $(RM) -r ./tmp $(Q) $(RM) *.log $(Q) $(MAKE) -C zdtm cleandep clean cleanout $(Q) $(MAKE) -C libcriu clean diff --git a/test/zdtm/live/static/fanotify00.c b/test/zdtm/live/static/fanotify00.c index 2cd0db2ed..45839541f 100644 --- a/test/zdtm/live/static/fanotify00.c +++ b/test/zdtm/live/static/fanotify00.c @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include @@ -202,10 +203,20 @@ int main (int argc, char *argv[]) int fa_fd, fd, del_after; char buf[BUFF_SIZE]; ssize_t length; - + int ns = getenv("ZDTM_NEWNS") != NULL; test_init(argc, argv); + if (ns) { + if (mkdir("/tmp", 666) && errno != EEXIST) { + err("Unable to create the /tmp directory"); + return -1; + } + if (mount("zdtm", "/tmp", "tmpfs", 0, NULL)) { + err("Unable to mount tmpfs into %s", "/tmp"); + } + } + fa_fd = fanotify_init(FAN_NONBLOCK | O_RDONLY | O_LARGEFILE | FAN_CLASS_NOTIF | FAN_UNLIMITED_QUEUE, 0); @@ -229,7 +240,7 @@ int main (int argc, char *argv[]) if (fanotify_mark(fa_fd, FAN_MARK_ADD | FAN_MARK_MOUNT, FAN_ONDIR | FAN_OPEN | FAN_CLOSE, - AT_FDCWD, "/")) { + AT_FDCWD, "/tmp")) { err("fanotify_mark failed\n"); exit(1); } @@ -237,7 +248,7 @@ int main (int argc, char *argv[]) if (fanotify_mark(fa_fd, FAN_MARK_ADD | FAN_MARK_MOUNT | FAN_MARK_IGNORED_MASK | FAN_MARK_IGNORED_SURV_MODIFY, FAN_MODIFY | FAN_ACCESS, - AT_FDCWD, "/")) { + AT_FDCWD, "/tmp")) { err("fanotify_mark failed\n"); exit(1); } @@ -283,7 +294,7 @@ int main (int argc, char *argv[]) if (fanotify_mark(fa_fd, FAN_MARK_REMOVE | FAN_MARK_MOUNT, FAN_ONDIR | FAN_OPEN | FAN_CLOSE, - AT_FDCWD, "/")) { + AT_FDCWD, "/tmp")) { err("fanotify_mark failed\n"); exit(1); }