From: Cyril Hrubis <chrubis@suse.cz>
To: Wei Gao <wegao@suse.com>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH 2/2] mount_setattr01: add open_tree_attr variant
Date: Fri, 29 Aug 2025 11:31:19 +0200 [thread overview]
Message-ID: <aLFzZ6xGsZh3CO64@yuki.lan> (raw)
In-Reply-To: <aLDhgFRA8ppAmYlH@localhost>
Hi!
> > +static int open_tree_variant1(struct mount_attr *attr)
> > +{
> > + tst_res(TINFO, "Variant using open_tree() + mount_setattr()");
> > +
> > + otfd = TST_EXP_FD(open_tree(AT_FDCWD, MNTPOINT,
> > + AT_EMPTY_PATH | OPEN_TREE_CLONE));
> > + if (otfd == -1)
> > + return -1;
> > +
> > + TST_EXP_PASS(mount_setattr(otfd, "", AT_EMPTY_PATH,
> > + attr, sizeof(*attr)));
> Duplicate mount_setattr? There is another mount_setattr after this
> called.
As far as I can tell the call that was done later has been removed in
this patch. That is because both of the variants do open_tree and
mount_setattr in the open_tree_variant() functions.
> > + if (TST_RET == -1)
> > + return -1;
> > +
> > + return otfd;
> > +}
> > +
> > +static int open_tree_variant2(struct mount_attr *attr)
> > +{
> > + tst_res(TINFO, "Variant using open_tree_attr()");
> > +
> > + otfd = TST_EXP_FD(open_tree_attr(AT_FDCWD, MNTPOINT,
> > + AT_EMPTY_PATH | OPEN_TREE_CLONE,
> > + attr, sizeof(*attr)));
> > +
> > + return otfd;
> > +}
> > +
> > static void run(unsigned int n)
> > {
> > struct tcase *tc = &tcases[n];
> > - struct mount_attr attr = {
> > - .attr_set = tc->mount_attrs,
> > - };
> > struct statvfs buf;
> >
> > - TST_EXP_FD_SILENT(open_tree(AT_FDCWD, MNTPOINT, AT_EMPTY_PATH |
> > - AT_SYMLINK_NOFOLLOW | OPEN_TREE_CLOEXEC | OPEN_TREE_CLONE));
> > - if (!TST_PASS)
> > - return;
> > + memset(attr, 0, sizeof(*attr));
> > + attr->attr_set = tc->mount_attrs;
> >
> > - otfd = (int)TST_RET;
> > + if (tst_variant)
> > + otfd = open_tree_variant1(attr);
> > + else
> > + otfd = open_tree_variant2(attr);
> I am not sure this is perfect way loop the function, add function point into struct tcase
> is better in my opinion.
The tst_variant was implemented exactly for the case where we have
different syscalls doing the same job. In this case a shortcut was added
that does open_tree + mount_setattr in a single syscall, so using
variants is very reasonable choice.
--
Cyril Hrubis
chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
next prev parent reply other threads:[~2025-08-29 9:31 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-28 13:11 [LTP] [PATCH 0/2] open_tree_attr syscall coverage Andrea Cervesato
2025-08-28 13:11 ` [LTP] [PATCH 1/2] Add open_tree_attr fallback Andrea Cervesato
2025-08-28 13:11 ` [LTP] [PATCH 2/2] mount_setattr01: add open_tree_attr variant Andrea Cervesato
2025-08-28 23:08 ` Wei Gao via ltp
2025-08-29 9:31 ` Cyril Hrubis [this message]
2025-08-29 12:06 ` Andrea Cervesato via ltp
2025-08-29 12:55 ` Cyril Hrubis
2025-09-01 10:28 ` Andrea Cervesato via ltp
2025-09-01 15:48 ` Cyril Hrubis
2025-08-29 12:06 ` Andrea Cervesato via ltp
2025-08-29 12:58 ` Cyril Hrubis
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aLFzZ6xGsZh3CO64@yuki.lan \
--to=chrubis@suse.cz \
--cc=ltp@lists.linux.it \
--cc=wegao@suse.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.