[LTP] [PATCH] unlink09: Fix open syscall flags

Sebastian Chlad sebastianchlad@gmail.com
Mon Jun 3 16:15:49 CEST 2024


+1

Reviewed-by: Sebastian Chlad <sebastianchlad@gmail.com>

On Mon, 3 Jun 2024 at 15:49, Andrea Cervesato via ltp <ltp@lists.linux.it>
wrote:

> 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 <andrea.cervesato@suse.com>
>
> On 6/3/24 14:46, Avinesh Kumar wrote:
> > In the SAFE_OPEN() calls, we missed to include any of the mandatory
> > flags for open syscall:  O_RDONLY,  O_WRONLY,  or  O_RDWR
> >
> > Fixes: 2cf78f47a6 (unlink: Add error tests for EPERM and EROFS)
> > Signed-off-by: Avinesh Kumar <akumar@suse.de>
> > ---
> >   testcases/kernel/syscalls/unlink/unlink09.c | 6 +++---
> >   1 file changed, 3 insertions(+), 3 deletions(-)
> >
> > diff --git a/testcases/kernel/syscalls/unlink/unlink09.c
> b/testcases/kernel/syscalls/unlink/unlink09.c
> > index cc4b4a07e..405deb05f 100644
> > --- a/testcases/kernel/syscalls/unlink/unlink09.c
> > +++ b/testcases/kernel/syscalls/unlink/unlink09.c
> > @@ -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;
>
> Andrea
>
>
> --
> Mailing list info: https://lists.linux.it/listinfo/ltp
>


More information about the ltp mailing list