[CRIU] [PATCH 3/3] zdtm/fanotify00: use /tmp instead of /
Andrey Vagin
avagin at openvz.org
Fri Aug 29 04:23:17 PDT 2014
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 <avagin at openvz.org>
---
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 1a6f6d2..d53c959 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 2812e33..2c15039 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 2cd0db2..4583954 100644
--- a/test/zdtm/live/static/fanotify00.c
+++ b/test/zdtm/live/static/fanotify00.c
@@ -5,6 +5,7 @@
#include <sys/types.h>
#include <sys/ioctl.h>
#include <sys/stat.h>
+#include <sys/mount.h>
#include <fcntl.h>
#include <string.h>
#include <stdio.h>
@@ -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);
}
--
1.9.3
More information about the CRIU
mailing list