[LTP] [PATCH] mknod01: Rewrite the test using new LTP API

Cyril Hrubis chrubis@suse.cz
Fri Feb 24 16:03:34 CET 2023


Hi!
> +	if (S_ISCHR(tcases[i]))
> +		dev = makedev(1, 3);
> +	else
> +		dev = 0;

Reading 'man 2 mknod' I suppose that we should pass non-zero dev for
block devices as well. Hoever the test seems to work fine with zero dev
for both cases.

Btw makedev(1, 3) seems to be the /dev/null char device and it should
work for block devices since block makedev(1, 3) would be /dev/ram3, so
what about:

diff --git a/testcases/kernel/syscalls/mknod/mknod01.c b/testcases/kernel/syscalls/mknod/mknod01.c
index d4b8c7bf8..7a4d5b43f 100644
--- a/testcases/kernel/syscalls/mknod/mknod01.c
+++ b/testcases/kernel/syscalls/mknod/mknod01.c
@@ -31,12 +31,10 @@ static int tcases[] = {

 static void run(unsigned int i)
 {
-       dev_t dev;
+       dev_t dev = 0;

-       if (S_ISCHR(tcases[i]))
+       if (S_ISCHR(tcases[i]) || S_ISBLK(tcases[i]))
                dev = makedev(1, 3);
-       else
-               dev = 0;

        TST_EXP_PASS(mknod(PATH, tcases[i], dev),
                                "mknod(PATH, %o, %ld)",


-- 
Cyril Hrubis
chrubis@suse.cz


More information about the ltp mailing list