2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-31 06:15:24 +00:00

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 <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
Andrey Vagin
2014-08-29 15:23:17 +04:00
committed by Pavel Emelyanov
parent 473a81df74
commit c5d238ef66
3 changed files with 17 additions and 4 deletions

1
test/.gitignore vendored
View File

@@ -3,5 +3,6 @@
/bin
/dev
/dump
/tmp
/*.log
/zdtm_ct

View File

@@ -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

View File

@@ -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);
}