unlink09: Fix open syscall flags
PATCH 1/1 unlink09: Fix open syscall flags
--- testcases/kernel/syscalls/unlink/unlink09.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
testcases/kernel/syscalls/unlink/unlink09.c +3 -3
@@ -43,12 +43,12 @@ static void setup(void) {int attr; - fd_immutable =SAFE_OPEN (TEST_EPERM_IMMUTABLE ,O_CREAT ,0600 ); + fd_immutable =SAFE_OPEN (TEST_EPERM_IMMUTABLE ,O_RDWR |O_CREAT ,0600 );SAFE_IOCTL (fd_immutable,FS_IOC_GETFLAGS , &attr); attr |=FS_IMMUTABLE_FL ;SAFE_IOCTL (fd_immutable,FS_IOC_SETFLAGS , &attr); - fd_append_only =SAFE_OPEN (TEST_EPERM_APPEND_ONLY ,O_CREAT ,0600 ); + fd_append_only =SAFE_OPEN (TEST_EPERM_APPEND_ONLY ,O_RDWR |O_CREAT ,0600 );SAFE_IOCTL (fd_append_only,FS_IOC_GETFLAGS , &attr); attr |=FS_APPEND_FL ;SAFE_IOCTL (fd_append_only,FS_IOC_SETFLAGS , &attr);
@@ -79,7 +79,7 @@ static void verify_unlink(unsigned int i)/* If unlink() succeeded unexpectedly, test file should be restored. */ if (!TST_RET ) {if (tc->fd) { - *(tc->fd) =SAFE_OPEN (tc->filename,O_CREAT ,0600 ); + *(tc->fd) =SAFE_OPEN (tc->filename,O_RDWR |O_CREAT ,0600 );if (tc->flag) {SAFE_IOCTL (*(tc->fd),FS_IOC_GETFLAGS , &attr); attr |= tc->flag;
Signature · 5 lines
2.45.1 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Hi Avinesh,
Could you please amend the git commit message to explain why that flag would be needed?
Thanks,
Seb/
Quoted 47 lines · Avinesh Kumar
Fixes 2cf78f47a6 (unlink: Add error tests for EPERM and EROFS)Signed-off-by Avinesh Kumar <[email protected]>--- testcases/kernel/syscalls/unlink/unlink09.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)testcases/kernel/syscalls/unlink/unlink09.c +2
-2@@ -43,12 +43,12 @@ static void setup(void) {int attr; - fd_immutable =SAFE_OPEN (TEST_EPERM_IMMUTABLE ,O_CREAT ,0600 ); + fd_immutable =SAFE_OPEN (TEST_EPERM_IMMUTABLE ,O_RDWR |O_CREAT ,0600 );SAFE_IOCTL (fd_immutable,FS_IOC_GETFLAGS , &attr); attr |=FS_IMMUTABLE_FL ;SAFE_IOCTL (fd_immutable,FS_IOC_SETFLAGS , &attr); - fd_append_only =SAFE_OPEN (TEST_EPERM_APPEND_ONLY ,O_CREAT ,0600 ); + fd_append_only =SAFE_OPEN (TEST_EPERM_APPEND_ONLY ,O_RDWR |O_CREAT ,0600 );SAFE_IOCTL (fd_append_only,FS_IOC_GETFLAGS , &attr);attr |= FS_APPEND_FL; SAFE_IOCTL(fd_append_only, FS_IOC_SETFLAGS, &attr);testcases/kernel/syscalls/unlink/unlink09.c +0
-0@@ -79,7 +79,7 @@ static void verify_unlink(unsigned int i)/* If unlink() succeeded unexpectedly, test file should be restored. */
if (!TST_RET) { if (tc->fd) {testcases/kernel/syscalls/unlink/unlink09.c +1
-1- *(tc->fd) =SAFE_OPEN (tc->filename,O_CREAT ,0600 ); + *(tc->fd) = SAFE_OPEN(tc->filename, O_RDWR |O_CREAT, 0600); if (tc->flag) { SAFE_IOCTL(*(tc->fd), FS_IOC_GETFLAGS, &attr); attr |= tc->flag;--
2.45.1--
Mailing list info: https://lists.linux.it/listinfo/ltp
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH 1/1 unlink09: Fix open syscall flags
In the SAFE_OPEN() calls, we missed to include any of the mandatory flags for open syscall: O_RDONLY, O_WRONLY, or O_RDWR
--- testcases/kernel/syscalls/unlink/unlink09.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
testcases/kernel/syscalls/unlink/unlink09.c +3 -3
@@ -43,12 +43,12 @@ static void setup(void) {int attr; - fd_immutable =SAFE_OPEN (TEST_EPERM_IMMUTABLE ,O_CREAT ,0600 ); + fd_immutable =SAFE_OPEN (TEST_EPERM_IMMUTABLE ,O_RDWR |O_CREAT ,0600 );SAFE_IOCTL (fd_immutable,FS_IOC_GETFLAGS , &attr); attr |=FS_IMMUTABLE_FL ;SAFE_IOCTL (fd_immutable,FS_IOC_SETFLAGS , &attr); - fd_append_only =SAFE_OPEN (TEST_EPERM_APPEND_ONLY ,O_CREAT ,0600 ); + fd_append_only =SAFE_OPEN (TEST_EPERM_APPEND_ONLY ,O_RDWR |O_CREAT ,0600 );SAFE_IOCTL (fd_append_only,FS_IOC_GETFLAGS , &attr); attr |=FS_APPEND_FL ;SAFE_IOCTL (fd_append_only,FS_IOC_SETFLAGS , &attr);
@@ -79,7 +79,7 @@ static void verify_unlink(unsigned int i)/* If unlink() succeeded unexpectedly, test file should be restored. */ if (!TST_RET ) {if (tc->fd) { - *(tc->fd) =SAFE_OPEN (tc->filename,O_CREAT ,0600 ); + *(tc->fd) =SAFE_OPEN (tc->filename,O_RDWR |O_CREAT ,0600 );if (tc->flag) {SAFE_IOCTL (*(tc->fd),FS_IOC_GETFLAGS , &attr); attr |= tc->flag;
Signature · 5 lines
2.45.1 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Hi!
thanks for fixing the commit message and the test. According with the open() documentation an access flag is a must and that's one thing that makes this test wrong.
LGTM
Quoted 29 lines · Avinesh Kumar
In the
SAFE_OPEN()calls, we missed to include any of the mandatory flags for open syscall:O_RDONLY,O_WRONLY, orO_RDWRFixes 2cf78f47a6 (unlink: Add error tests for EPERM and EROFS)Signed-off-by Avinesh Kumar <[email protected]>--- testcases/kernel/syscalls/unlink/unlink09.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)testcases/kernel/syscalls/unlink/unlink09.c +2
-2@@ -43,12 +43,12 @@ static void setup(void) {int attr; - fd_immutable =SAFE_OPEN (TEST_EPERM_IMMUTABLE ,O_CREAT ,0600 ); + fd_immutable =SAFE_OPEN (TEST_EPERM_IMMUTABLE ,O_RDWR |O_CREAT ,0600 );SAFE_IOCTL (fd_immutable,FS_IOC_GETFLAGS , &attr); attr |=FS_IMMUTABLE_FL ;SAFE_IOCTL (fd_immutable,FS_IOC_SETFLAGS , &attr); - fd_append_only =SAFE_OPEN (TEST_EPERM_APPEND_ONLY ,O_CREAT ,0600 ); + fd_append_only =SAFE_OPEN (TEST_EPERM_APPEND_ONLY ,O_RDWR |O_CREAT ,0600 );SAFE_IOCTL (fd_append_only,FS_IOC_GETFLAGS , &attr); attr |=FS_APPEND_FL ;SAFE_IOCTL (fd_append_only,FS_IOC_SETFLAGS , &attr);
testcases/kernel/syscalls/unlink/unlink09.c static void verify_unlink(unsigned int i) · line 85
Quoted 8 lines
testcases/kernel/syscalls/unlink/unlink09.c +1
-1@@ -79,7 +79,7 @@ static void verify_unlink(unsigned int i)/* If unlink() succeeded unexpectedly, test file should be restored. */ if (!TST_RET ) {if (tc->fd) { - *(tc->fd) =SAFE_OPEN (tc->filename,O_CREAT ,0600 ); + *(tc->fd) =SAFE_OPEN (tc->filename,O_RDWR |O_CREAT ,0600 );if (tc->flag) {SAFE_IOCTL (*(tc->fd),FS_IOC_GETFLAGS , &attr); attr |= tc->flag;
Andrea
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Sebastian Chlad
Reviewed-by+1
Quoted 61 lines · Andrea Cervesato via ltp
Hi!
thanks for fixing the commit message and the test. According with the
open()documentation an access flag
is a must and that's one thing that makes this test wrong.LGTM
Reviewed-by Andrea Cervesato <[email protected]>Review
Quoted 10 lines · Avinesh Kumar
In the
SAFE_OPEN()calls, we missed to include any of the mandatory flags for open syscall:O_RDONLY,O_WRONLY, orO_RDWRFixes 2cf78f47a6 (unlink: Add error tests for EPERM and EROFS)Signed-off-by Avinesh Kumar <[email protected]>--- testcases/kernel/syscalls/unlink/unlink09.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)(quoted diff) +0
-0
b/testcases/kernel/syscalls/unlink/unlink09.ctestcases/kernel/syscalls/unlink/unlink09.c static void setup(void) · line 46
Quoted 9 lines
index
cc4b4a07e..405deb05f100644testcases/kernel/syscalls/unlink/unlink09.c +1
-1@@ -43,12 +43,12 @@ static void setup(void) {int attr; - fd_immutable =SAFE_OPEN (TEST_EPERM_IMMUTABLE ,O_CREAT ,0600 ); + fd_immutable = SAFE_OPEN(TEST_EPERM_IMMUTABLE, O_RDWR | O_CREAT,0600);
testcases/kernel/syscalls/unlink/unlink09.c static void setup(void)
Quoted 6 lines
testcases/kernel/syscalls/unlink/unlink09.c +1
-1SAFE_IOCTL (fd_immutable,FS_IOC_GETFLAGS , &attr); attr |=FS_IMMUTABLE_FL ;SAFE_IOCTL (fd_immutable,FS_IOC_SETFLAGS , &attr); - fd_append_only =SAFE_OPEN (TEST_EPERM_APPEND_ONLY ,O_CREAT ,0600 ); + fd_append_only = SAFE_OPEN(TEST_EPERM_APPEND_ONLY, O_RDWR |
O_CREAT, 0600);testcases/kernel/syscalls/unlink/unlink09.c static void verify_unlink(unsigned int i) · line 79
Quoted 5 lines
testcases/kernel/syscalls/unlink/unlink09.c +0
-0SAFE_IOCTL (fd_append_only,FS_IOC_GETFLAGS , &attr); attr |=FS_APPEND_FL ;SAFE_IOCTL (fd_append_only,FS_IOC_SETFLAGS , &attr);@@ -79,7 +79,7 @@ static void verify_unlink(unsigned int i)/* If unlink() succeeded unexpectedly, test file should be restored. */
testcases/kernel/syscalls/unlink/unlink09.c static void verify_unlink(unsigned int i)
Quoted 4 lines
testcases/kernel/syscalls/unlink/unlink09.c +1
-1if (!TST_RET ) {if (tc->fd) { - *(tc->fd) =SAFE_OPEN (tc->filename,O_CREAT ,0600 ); + *(tc->fd) = SAFE_OPEN(tc->filename, O_RDWR |
O_CREAT, 0600);testcases/kernel/syscalls/unlink/unlink09.c static void verify_unlink(unsigned int i) · line 84
Quoted 2 lines
testcases/kernel/syscalls/unlink/unlink09.c +0
-0if (tc->flag) { SAFE_IOCTL(*(tc->fd), FS_IOC_GETFLAGS,&attr);
testcases/kernel/syscalls/unlink/unlink09.c static void verify_unlink(unsigned int i) · line 85
Quoted 1 line
testcases/kernel/syscalls/unlink/unlink09.c +0
-0attr |= tc->flag;Andrea
--
Mailing list info: https://lists.linux.it/listinfo/ltp
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Hi all,
I suppose with this fix Andrea's extra check is not needed, right? But sure, it would not harm anyway.
It'd be still interesting to know what exactly triggered the problem.
https://patchwork.ozlabs.org/project/ltp/patch/[email protected]/
Kind regards,
Petr
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Hi,
Unfortunately this patch is not working, due to the fact test requires to check if filesystem supports inode attributes. OPEN_CREAT() is more appropriate in this case and please refer to the following patch instead, since it's fixing the issue:
https://patchwork.ozlabs.org/project/ltp/patch/[email protected]/
Andrea
Quoted 13 lines · Petr Vorel
Hi all,
Reviewed-by Petr Vorel <[email protected]>I suppose with this fix Andrea's extra check is not needed, right? But sure, it would not harm anyway.
It'd be still interesting to know what exactly triggered the problem.
https://patchwork.ozlabs.org/project/ltp/patch/[email protected]/
Kind regards,
Petr
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Hi all,
just to document, we agreed in discussion of alternative patch, that more fixes are needed, thus setting this in patchwork as changes requested.
https://lore.kernel.org/ltp/[email protected]/
https://patchwork.ozlabs.org/project/ltp/patch/[email protected]/
Kind regards,
Petr
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp