[LTP] [PATCH v3] ioctl_loop01.c: Use proper device for partitioning

Wei Gao wegao@suse.com
Wed Sep 24 12:40:53 CEST 2025


On Wed, Sep 24, 2025 at 11:54:00AM +0200, Cyril Hrubis wrote:
> Hi!
> > What's difference between needs_foo and wants_foo? wants_foo means we do
> > not do brk if not exist foo?
> > I guess we need wants_parted support for .needs_cmds like following
> > change? Could you give me more guidance
> > 
> > --- a/testcases/kernel/syscalls/ioctl/ioctl_loop01.c
> > +++ b/testcases/kernel/syscalls/ioctl/ioctl_loop01.c
> > @@ -147,6 +147,10 @@ static struct tst_test test = {
> >                 "loop",
> >                 NULL
> >         },
> > +       .needs_cmds= (const char *const []) {
> > +               "wants_parted",
> > +               NULL
> > +       },
> 
> As Peter explained support for this is not in the test library yet.
> 
> My proposal was either of:
> 
> 1. Add .wants_cmd key to the tst_test structure
>   - pros: easy to add, easy to handle
>   - cons: the number of tst_test structure members will eventually
>     double
> 
> 2. Add a flag to the needs_cmd, i.e. convert needs_cmd into an array of
>    structures, we do that for other cases like saving and restoring
>    proc/sys files
>    - pros: we will keep the number of members of tst_test
>            this is easily expandable, e.g. adding support for
> 	   minimal version
>    - cons: all tests that have needs cmds will need to be adjusted
> 
> This would look like:
> 
> struct tst_cmd {
> 	const char *cmd;
> 	unsigned int required:1;
> };
> 
> 
> After thinking about this I've started to lean towards option 2.
If we select option 2 then we have following setting for all related
test cases.
+       .needs_cmds = (const struct tst_cmd[]) {
+               {"parted", "0"},
+               {}
+       },

But how to get "parted" command support status? In ioctl_loop01.c there
is a local var "parted_sup" which flag parted command support or not, and
use this flag to decide which sub test needed. 
If we do this logic in test lib then we need create another
flag in tst_cmd used for give status of command support or not.
During test lib logic will set tst_cmd.support flag.

 struct tst_cmd {
 	const char *cmd;
 	unsigned int required:1;
 	unsigned int support:1;
 };

Correct me if any misunderstanding, many thanks.

> 
> -- 
> Cyril Hrubis
> chrubis@suse.cz


More information about the ltp mailing list