Skip to content

Commit c180188

Browse files
Snorchavagin
authored andcommitted
zdtm: fix incorrect open() syscall use for file creation without mode
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 <ptikhomirov@virtuozzo.com>
1 parent f22c95d commit c180188

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

test/zdtm/static/fanotify00.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ int main(int argc, char *argv[])
223223
exit(1);
224224
}
225225

226-
del_after = open(fanotify_path, O_CREAT | O_TRUNC);
226+
del_after = open(fanotify_path, O_CREAT | O_TRUNC, 0777);
227227
if (del_after < 0) {
228228
pr_perror("open failed");
229229
exit(1);

test/zdtm/static/mountpoints.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,15 +96,15 @@ int main(int argc, char **argv)
9696
fail("Can't mount tmpfs");
9797
return 1;
9898
}
99-
tmpfs_fd = open(MPTS_ROOT "/dev/test", O_WRONLY | O_CREAT);
99+
tmpfs_fd = open(MPTS_ROOT "/dev/test", O_WRONLY | O_CREAT, 0777);
100100
if (write(tmpfs_fd, "hello", 5) <= 0) {
101101
pr_perror("write() failed");
102102
return 1;
103103
}
104104

105105
/* Check that over-mounted files are restored on tmpfs */
106106
mkdir(MPTS_ROOT "/dev/overmount", 0600);
107-
fd = open(MPTS_ROOT "/dev/overmount/test.over", O_WRONLY | O_CREAT);
107+
fd = open(MPTS_ROOT "/dev/overmount/test.over", O_WRONLY | O_CREAT, 0777);
108108
if (fd == -1) {
109109
pr_perror("Unable to open " MPTS_ROOT "/dev/overmount");
110110
return -1;
@@ -190,14 +190,14 @@ int main(int argc, char **argv)
190190
}
191191
mkdir(MPTS_ROOT "/dev/slave/test.mnt.slave/test.slave", 0600);
192192

193-
fd = open(MPTS_ROOT "/dev/bmfile", O_CREAT | O_WRONLY);
193+
fd = open(MPTS_ROOT "/dev/bmfile", O_CREAT | O_WRONLY, 0777);
194194
if (fd < 0) {
195195
pr_perror("Can't create " MPTS_ROOT "/dev/share-1/bmfile");
196196
return 1;
197197
}
198198
close(fd);
199199

200-
fd = open(MPTS_ROOT "/dev/bmfile-mount", O_CREAT | O_WRONLY);
200+
fd = open(MPTS_ROOT "/dev/bmfile-mount", O_CREAT | O_WRONLY, 0777);
201201
if (fd < 0) {
202202
pr_perror("Can't create " MPTS_ROOT "/dev/share-1/bmfile");
203203
return 1;

0 commit comments

Comments
 (0)