From c180188db036f8ea4c08bfee28cbcdbdd52cdfc3 Mon Sep 17 00:00:00 2001 From: Pavel Tikhomirov Date: Thu, 26 Feb 2026 19:11:41 +0100 Subject: [PATCH] zdtm: fix incorrect open() syscall use for file creation without mode MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We saw compilation errors like: error: call to ‘__open_missing_mode’ declared with attribute error: open with O_CREAT or O_TMPFILE in second argument needs 3 arguments Let's fix them by adding mode 0777 everywhere. Before this change the mode was taken randomly from stack (according to man 2 open) and that is likely not what we want. Signed-off-by: Pavel Tikhomirov --- test/zdtm/static/fanotify00.c | 2 +- test/zdtm/static/mountpoints.c | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/test/zdtm/static/fanotify00.c b/test/zdtm/static/fanotify00.c index 0400cc74b..dfc30bb6c 100644 --- a/test/zdtm/static/fanotify00.c +++ b/test/zdtm/static/fanotify00.c @@ -223,7 +223,7 @@ int main(int argc, char *argv[]) exit(1); } - del_after = open(fanotify_path, O_CREAT | O_TRUNC); + del_after = open(fanotify_path, O_CREAT | O_TRUNC, 0777); if (del_after < 0) { pr_perror("open failed"); exit(1); diff --git a/test/zdtm/static/mountpoints.c b/test/zdtm/static/mountpoints.c index b5fd72aad..a8a2141ac 100644 --- a/test/zdtm/static/mountpoints.c +++ b/test/zdtm/static/mountpoints.c @@ -96,7 +96,7 @@ int main(int argc, char **argv) fail("Can't mount tmpfs"); return 1; } - tmpfs_fd = open(MPTS_ROOT "/dev/test", O_WRONLY | O_CREAT); + tmpfs_fd = open(MPTS_ROOT "/dev/test", O_WRONLY | O_CREAT, 0777); if (write(tmpfs_fd, "hello", 5) <= 0) { pr_perror("write() failed"); return 1; @@ -104,7 +104,7 @@ int main(int argc, char **argv) /* Check that over-mounted files are restored on tmpfs */ mkdir(MPTS_ROOT "/dev/overmount", 0600); - fd = open(MPTS_ROOT "/dev/overmount/test.over", O_WRONLY | O_CREAT); + fd = open(MPTS_ROOT "/dev/overmount/test.over", O_WRONLY | O_CREAT, 0777); if (fd == -1) { pr_perror("Unable to open " MPTS_ROOT "/dev/overmount"); return -1; @@ -190,14 +190,14 @@ int main(int argc, char **argv) } mkdir(MPTS_ROOT "/dev/slave/test.mnt.slave/test.slave", 0600); - fd = open(MPTS_ROOT "/dev/bmfile", O_CREAT | O_WRONLY); + fd = open(MPTS_ROOT "/dev/bmfile", O_CREAT | O_WRONLY, 0777); if (fd < 0) { pr_perror("Can't create " MPTS_ROOT "/dev/share-1/bmfile"); return 1; } close(fd); - fd = open(MPTS_ROOT "/dev/bmfile-mount", O_CREAT | O_WRONLY); + fd = open(MPTS_ROOT "/dev/bmfile-mount", O_CREAT | O_WRONLY, 0777); if (fd < 0) { pr_perror("Can't create " MPTS_ROOT "/dev/share-1/bmfile"); return 1;