From 9d03d77f20f9ebc0e56dba86cd31b9491d399c0b Mon Sep 17 00:00:00 2001 From: Andrew Vagin Date: Fri, 29 Apr 2016 01:09:00 +0300 Subject: [PATCH] zdtm: check a ghost file in a read-only directory =[log]=> dump/zdtm/static/unlink_fstat00/39/1/restore.log ------------------------ grep Error ------------------------ (00.097701) 4: Error (files-reg.c:1231): Can't link zdtm/static/unlink_fstat00.test/test\file' (00.097707) 4: Error (files-reg.c:1431): Can't link zdtm/static/unlink_fstat00.test/test\file' (00.097952) 1: Error (cr-restore.c:1404): 4 exited, status=1 (00.108085) Error (cr-restore.c:1407): 64 killed by signal 9: Killed (00.114341) Error (cr-restore.c:2246): Restoring FAILED. ------------------------ ERROR OVER ------------------------ v2: add a new test instead of changing the existing one. Signed-off-by: Andrew Vagin Signed-off-by: Pavel Emelyanov --- test/zdtm/.gitignore | 1 + test/zdtm/static/Makefile | 2 ++ test/zdtm/static/unlink_fstat00.c | 21 +++++++++++++++++++++ test/zdtm/static/unlink_fstat04.c | 1 + test/zdtm/static/unlink_fstat04.desc | 1 + 5 files changed, 26 insertions(+) create mode 120000 test/zdtm/static/unlink_fstat04.c create mode 100644 test/zdtm/static/unlink_fstat04.desc diff --git a/test/zdtm/.gitignore b/test/zdtm/.gitignore index 408d5c0cc..7a1986874 100644 --- a/test/zdtm/.gitignore +++ b/test/zdtm/.gitignore @@ -185,6 +185,7 @@ /static/unlink_fstat01+ /static/unlink_fstat02 /static/unlink_fstat03 +/static/unlink_fstat04 /static/unlink_largefile /static/unlink_mmap00 /static/unlink_mmap01 diff --git a/test/zdtm/static/Makefile b/test/zdtm/static/Makefile index 42fcf8184..2e53417e5 100644 --- a/test/zdtm/static/Makefile +++ b/test/zdtm/static/Makefile @@ -219,6 +219,7 @@ TST_DIR = \ cgroup02 \ cgroup03 \ cgroup_stray \ + unlink_fstat04 \ mntns_open \ mntns_link_remap \ mntns_link_ghost \ @@ -376,6 +377,7 @@ maps02: get_smaps_bits.o mlock_setuid: get_smaps_bits.o inotify01: override CFLAGS += -DINOTIFY01 unlink_fstat01+: override CFLAGS += -DUNLINK_OVER +unlink_fstat04: override CFLAGS += -DUNLINK_FSTAT04 sk-freebind-false: override CFLAGS += -DZDTM_FREEBIND_FALSE stopped01: override CFLAGS += -DZDTM_STOPPED_KILL stopped02: override CFLAGS += -DZDTM_STOPPED_TKILL diff --git a/test/zdtm/static/unlink_fstat00.c b/test/zdtm/static/unlink_fstat00.c index 4965dbc05..f741099bf 100644 --- a/test/zdtm/static/unlink_fstat00.c +++ b/test/zdtm/static/unlink_fstat00.c @@ -5,13 +5,19 @@ #include #include #include +#include #include "zdtmtst.h" const char *test_doc = "Open, unlink, change size, seek, migrate, check size"; +#ifdef UNLINK_FSTAT04 +char *dirname; +TEST_OPTION(dirname, string, "directory name", 1); +#else char *filename; TEST_OPTION(filename, string, "file name", 1); +#endif int main(int argc, char ** argv) { @@ -23,15 +29,30 @@ int main(int argc, char ** argv) uint8_t buf[fsize]; struct stat fst; uint32_t crc; +#ifdef UNLINK_FSTAT04 + char filename[PATH_MAX]; +#endif test_init(argc, argv); +#ifdef UNLINK_FSTAT04 + snprintf(filename, sizeof(filename), "%s/test\\file'\n\"un%%linkfstat00", dirname); + + mkdir(dirname, 0700); +#endif fd = open(filename, O_RDWR | O_CREAT | O_TRUNC, 0644); if (fd < 0) { pr_perror("can't open %s", filename); exit(1); } +#ifdef UNLINK_FSTAT04 + if (chmod(dirname, 0500)) { + pr_perror("chmod"); + exit(1); + } +#endif + if (fstat(fd, &fst) < 0) { pr_perror("can't get file info %s before", filename); goto failed; diff --git a/test/zdtm/static/unlink_fstat04.c b/test/zdtm/static/unlink_fstat04.c new file mode 120000 index 000000000..f51b3c63b --- /dev/null +++ b/test/zdtm/static/unlink_fstat04.c @@ -0,0 +1 @@ +unlink_fstat00.c \ No newline at end of file diff --git a/test/zdtm/static/unlink_fstat04.desc b/test/zdtm/static/unlink_fstat04.desc new file mode 100644 index 000000000..48e131a8e --- /dev/null +++ b/test/zdtm/static/unlink_fstat04.desc @@ -0,0 +1 @@ +{ "flags" : "suid" }