Add missing mode argument to open(..., O_CREAT)
PATCH 1/1 Add missing mode argument to open(..., O_CREAT)
--- testcases/kernel/syscalls/fallocate/fallocate05.c | 5 +++-- testcases/kernel/syscalls/fallocate/fallocate06.c | 4 ++-- testcases/kernel/syscalls/getdents/getdents02.c | 2 +- testcases/kernel/syscalls/io_pgetevents/io_pgetevents01.c | 2 +- testcases/kernel/syscalls/io_pgetevents/io_pgetevents02.c | 2 +- testcases/kernel/syscalls/kcmp/kcmp01.c | 2 +- testcases/kernel/syscalls/kcmp/kcmp02.c | 4 ++-- testcases/kernel/syscalls/msync/msync04.c | 3 ++- testcases/kernel/syscalls/tee/tee02.c | 2 +- 9 files changed, 14 insertions(+), 12 deletions(-)
testcases/kernel/syscalls/fallocate/fallocate05.c +3 -2
@@ -39,7 +39,7 @@ static void setup(void)int fd;struct stat statbuf; - fd =SAFE_OPEN (MNTPOINT "/test_file" ,O_WRONLY |O_CREAT ); + fd =SAFE_OPEN (MNTPOINT "/test_file" ,O_WRONLY |O_CREAT ,0644 );/* * Use real FS block size, otherwise fallocate() call will test
@@ -57,7 +57,8 @@ static void run(void)int fd;long extsize, tmp; - fd =SAFE_OPEN (MNTPOINT "/test_file" ,O_WRONLY |O_CREAT |O_TRUNC ); + fd =SAFE_OPEN (MNTPOINT "/test_file" ,O_WRONLY |O_CREAT |O_TRUNC , +0644 );TEST (fallocate (fd,0 ,0 , bufsize));if (TST_RET ) {
testcases/kernel/syscalls/fallocate/fallocate06.c +2 -2
@@ -77,7 +77,7 @@ static void setup(void)int fd;struct stat statbuf; - fd =SAFE_OPEN (TEMPFILE ,O_WRONLY |O_CREAT |O_TRUNC ); + fd =SAFE_OPEN (TEMPFILE ,O_WRONLY |O_CREAT |O_TRUNC ,0644 );/* * Set FS_NOCOW_FL flag on the temp file. Non-CoW filesystems will
@@ -166,7 +166,7 @@ static void run(unsigned int n)tst_res (TINFO ,"Case %u. Fill FS: %s; Use copy on write: %s" , n+1 , tc->fill_fs ?"yes" :"no" , tc->no_cow ?"no" :"yes" ); - fd =SAFE_OPEN (TEMPFILE ,O_RDWR |O_CREAT |O_TRUNC ); + fd =SAFE_OPEN (TEMPFILE ,O_RDWR |O_CREAT |O_TRUNC ,0644 );if (cow_support)toggle_cow (fd, !tc->no_cow);
testcases/kernel/syscalls/getdents/getdents02.c +1 -1
@@ -158,7 +158,7 @@ static void test_enotdir(void)struct linux_dirent64 dir64;struct linux_dirent dir; - fd =SAFE_OPEN (cleanup,"test" ,O_CREAT |O_RDWR ); + fd =SAFE_OPEN (cleanup,"test" ,O_CREAT |O_RDWR ,0644 );if (longsyscall)getdents64 (fd, &dir64,sizeof (dir64));
testcases/kernel/syscalls/io_pgetevents/io_pgetevents01.c +1 -1
@@ -29,7 +29,7 @@ static void run(void) cbs[0 ] = &cb;sigemptyset (&sigmask); - fd =SAFE_OPEN ("io_pgetevents_file" ,O_RDWR |O_CREAT ); + fd =SAFE_OPEN ("io_pgetevents_file" ,O_RDWR |O_CREAT ,0644 );io_prep_pwrite (&cb, fd, data,4096 ,0 ); ret =io_setup (1 , &ctx);
testcases/kernel/syscalls/io_pgetevents/io_pgetevents02.c +1 -1
@@ -42,7 +42,7 @@ static void setup(void)sigemptyset (&sigmask); - fd =SAFE_OPEN ("io_pgetevents_file" ,O_RDWR |O_CREAT ); + fd =SAFE_OPEN ("io_pgetevents_file" ,O_RDWR |O_CREAT ,0644 );io_prep_pwrite (&cb, fd, data,4096 ,0 ); ret =io_setup (1 , &ctx);
testcases/kernel/syscalls/kcmp/kcmp01.c +1 -1
@@ -43,7 +43,7 @@ static struct test_case {static void setup (void ) { - fd1 =SAFE_OPEN (TEST_FILE ,O_CREAT |O_RDWR |O_TRUNC ); + fd1 =SAFE_OPEN (TEST_FILE ,O_CREAT |O_RDWR |O_TRUNC ,0666 ); }static void cleanup (void )
testcases/kernel/syscalls/kcmp/kcmp02.c +2 -2
@@ -54,8 +54,8 @@ static void setup(void) pid1 =getpid (); pid_unused =tst_get_unused_pid (); - fd1 =SAFE_OPEN (TEST_FILE ,O_CREAT |O_RDWR |O_TRUNC ); - fd2 =SAFE_OPEN (TEST_FILE2 ,O_CREAT |O_RDWR |O_TRUNC ); + fd1 =SAFE_OPEN (TEST_FILE ,O_CREAT |O_RDWR |O_TRUNC ,0644 ); + fd2 =SAFE_OPEN (TEST_FILE2 ,O_CREAT |O_RDWR |O_TRUNC ,0644 ); }static void cleanup (void )
testcases/kernel/syscalls/msync/msync04.c +2 -1
@@ -47,7 +47,8 @@ static void test_msync(void) {uint64_t dirty; - test_fd =SAFE_OPEN ("msync04/testfile" ,O_CREAT |O_TRUNC |O_RDWR ); + test_fd =SAFE_OPEN ("msync04/testfile" ,O_CREAT |O_TRUNC |O_RDWR , +0644 );SAFE_WRITE (0 , test_fd,STRING_TO_WRITE ,sizeof (STRING_TO_WRITE ) -1 ); mmaped_area =SAFE_MMAP (NULL , pagesize,PROT_READ |PROT_WRITE ,MAP_SHARED , test_fd,0 );
testcases/kernel/syscalls/tee/tee02.c +1 -1
@@ -44,7 +44,7 @@ static struct tcase {static void setup (void ) { - fd =SAFE_OPEN (TEST_FILE ,O_RDWR |O_CREAT ); + fd =SAFE_OPEN (TEST_FILE ,O_RDWR |O_CREAT ,0644 );SAFE_PIPE (pipes);SAFE_WRITE (1 , pipes[1 ],STR ,sizeof (STR ) -1 ); }
Signature · 1 line
2.26.2
PATCH 1/1 Add missing mode argument to open(..., O_CREAT)
Hi Marting,
thank you, good catch.
According to man open(2), mode must be specified when O_CREAT or O_TMPFILE is specified in flags. Thus it looks to me that also these files are missing mode:
testcases/kernel/syscalls/fallocate/fallocate05.c
fd = SAFE_OPEN(MNTPOINT "/test_file", O_WRONLY | O_CREAT); fd = SAFE_OPEN(MNTPOINT "/test_file", O_WRONLY | O_CREAT | O_TRUNC);
testcases/kernel/syscalls/fallocate/fallocate06.c fd = SAFE_OPEN(TEMPFILE, O_RDWR | O_CREAT | O_TRUNC);
Kind regards,
Petr
PATCH 1/1 Add missing mode argument to open(..., O_CREAT)
Hi Martin,
Quoted 9 lines
According to man open(2), mode must be specified when
O_CREATorO_TMPFILEis specified in flags. Thus it looks to me that also these files are missing mode:
testcases/kernel/syscalls/fallocate/fallocate05.c
fd =SAFE_OPEN(MNTPOINT "/test_file", O_WRONLY | O_CREAT); fd =SAFE_OPEN(MNTPOINT "/test_file", O_WRONLY | O_CREAT | O_TRUNC);
testcases/kernel/syscalls/fallocate/fallocate06.cfd =SAFE_OPEN(TEMPFILE, O_RDWR | O_CREAT | O_TRUNC);
I'm sorry, I accidentally looked at the master for these 2 files (switching between branches a lot). Sorry for the noise, merged.
Kind regards,
Petr