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" }