[CRIU] [PATCH 4/5] fown: test -- Update file_own_dead to test O_PATH case
Cyrill Gorcunov
gorcunov at gmail.com
Fri Dec 7 15:29:47 MSK 2018
Signed-off-by: Cyrill Gorcunov <gorcunov at gmail.com>
---
test/zdtm/static/Makefile | 2 +-
test/zdtm/static/file_fown_dead.c | 19 +++++++++++++++++++
2 files changed, 20 insertions(+), 1 deletion(-)
diff --git a/test/zdtm/static/Makefile b/test/zdtm/static/Makefile
index ab20c61b3574..2d7bd9c7bc5b 100644
--- a/test/zdtm/static/Makefile
+++ b/test/zdtm/static/Makefile
@@ -119,7 +119,6 @@ TST_NOFILE := \
groups \
pdeath_sig \
file_fown \
- file_fown_dead \
proc-self \
eventfs00 \
epoll \
@@ -279,6 +278,7 @@ TST_FILE = \
netns-nf \
maps_file_prot \
socket_close_data01 \
+ file_fown_dead \
TST_DIR = \
cwd00 \
diff --git a/test/zdtm/static/file_fown_dead.c b/test/zdtm/static/file_fown_dead.c
index 3a99bc729f51..92c6d0ad9dc7 100644
--- a/test/zdtm/static/file_fown_dead.c
+++ b/test/zdtm/static/file_fown_dead.c
@@ -22,6 +22,9 @@
const char *test_doc = "Check for restore with dead file owners";
const char *test_author = "Cyrill Gorcunov <gorcunov at openvz.org>";
+char *filename;
+TEST_OPTION(filename, string, "file name", 1);
+
struct params {
int sigio;
int pipe_flags[2];
@@ -81,9 +84,23 @@ int main(int argc, char *argv[])
uid_t ruid, euid, suid;
int status, pipes[2];
pid_t pid;
+ int fd;
test_init(argc, argv);
+ fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC | O_EXCL, 0644);
+ if (fd < 0) {
+ pr_perror("Can't create %s", filename);
+ exit(1);
+ }
+ close(fd);
+
+ fd = open(filename, O_PATH, 0644);
+ if (fd < 0) {
+ pr_perror("Can't open %s as O_PATH", filename);
+ exit(1);
+ }
+
shared = (void *)mmap(NULL, 4096, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANONYMOUS, -1, 0);
if ((void *)shared == MAP_FAILED) {
fail("mmap failed");
@@ -187,6 +204,8 @@ int main(int argc, char *argv[])
exit(1);
}
+ close(fd);
+
pass();
return 0;
}
--
2.17.2
More information about the CRIU
mailing list