[LTP] [PATCH v3 2/8] syscalls/mknod02: Use relative path to avoid use of SAFE_CHDIR

Li Wang liwang@redhat.com
Thu May 15 04:49:29 CEST 2025


On Tue, Apr 22, 2025 at 9:06 PM Petr Vorel <pvorel@suse.cz> wrote:
>
> Hi Ricardo, all,
>
> ...
> > +++ b/testcases/kernel/syscalls/mknod/mknod02.c
> > @@ -20,7 +20,7 @@
> >  #define MODE_SGID    02000
>
> >  #define TEMP_DIR "testdir"
> > -#define TEMP_NODE "testnode"
> > +#define TEMP_NODE TEMP_DIR "/testnode"
>
> >  static struct stat buf;
> >  static struct passwd *user_nobody;
> > @@ -37,14 +37,12 @@ static void setup(void)
>
> >  static void run(void)
> >  {
> > -     SAFE_CHDIR(TEMP_DIR);
> >       TST_EXP_PASS(mknod(TEMP_NODE, MODE1, 0), "mknod(%s, %o, 0)", TEMP_NODE, MODE1);
>
> >       SAFE_STAT(TEMP_NODE, &buf);
> >       TST_EXP_EQ_LI(buf.st_gid, 0);
>
> >       SAFE_UNLINK(TEMP_NODE);
> > -     SAFE_CHDIR("..");
>
> I'm trying to figure out why the original test used SAFE_CHDIR().

I guess that was simply added just by the new API conversion. It's
safe to remove it

> IMHO mknod() should not be affected when called from an upper directory.
> @Avinesh @Li did I overlook something obvious?

No, you're not overlooking anything obvious. mknod() doesn't care
about the directory you're in, as long as the pathname is correct.

And sorry for the late, I definitely missed this email :).

-- 
Regards,
Li Wang



More information about the ltp mailing list