From: Petr Vorel <pvorel@suse.cz>
To: Chen Hanxiao <chenhx.fnst@fujitsu.com>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH v5] syscalls/mount_setattr01: Add basic functional test
Date: Wed, 18 May 2022 10:50:51 +0200 [thread overview]
Message-ID: <YoSzazXY+BRhAPmc@pevik> (raw)
In-Reply-To: <20220428104642.110-1-chenhx.fnst@fujitsu.com>
Hi Chen, Dai,
...
> +static void setup(void)
> +{
> + fsopen_supported_by_kernel();
> + struct stat st = {0};
> +
> + if (stat(OT_MNTPOINT, &st) == -1)
> + SAFE_MKDIR(OT_MNTPOINT, 0777);
> +}
> +
> +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;
> +
> + otfd = (int)TST_RET;
> +
> + TST_EXP_PASS_SILENT(mount_setattr(otfd, "", AT_EMPTY_PATH, &attr, sizeof(attr)),
> + "%s set", tc->name);
> + if (!TST_PASS)
> + goto out1;
> +
> + TST_EXP_PASS_SILENT(move_mount(otfd, "", AT_FDCWD, OT_MNTPOINT, MOVE_MOUNT_F_EMPTY_PATH));
> + if (!TST_PASS)
> + goto out1;
> + mount_flag = 1;
> + SAFE_CLOSE(otfd);
> +
> + TST_EXP_PASS_SILENT(statvfs(OT_MNTPOINT, &buf), "statvfs sucess");
> + if (!TST_PASS)
> + goto out2;
> +
> + if (buf.f_flag & tc->expect_attrs)
> + tst_res(TPASS, "%s is actually set as expected", tc->name);
> + else
> + tst_res(TFAIL, "%s is not actually set as expected", tc->name);
> +
> + goto out2;
> +
> +out1:
> + SAFE_CLOSE(otfd);
> +out2:
> + mount_flag = 0;
> + SAFE_UMOUNT(OT_MNTPOINT);
mount_flag needs to be checked before otherwise if it fails on:
TST_EXP_PASS_SILENT(mount_setattr(otfd, "", AT_EMPTY_PATH, &attr, sizeof(attr)),
"%s set", tc->name);
It tries to umount() not yet mounted filesystem:
mount_setattr01.c:109: TPASS: MOUNT_ATTR_RDONLY is actually set as expected
mount_setattr01.c:109: TPASS: MOUNT_ATTR_NOSUID is actually set as expected
mount_setattr01.c:109: TPASS: MOUNT_ATTR_NODEV is actually set as expected
mount_setattr01.c:109: TPASS: MOUNT_ATTR_NOEXEC is actually set as expected
mount_setattr01.c:93: TFAIL: MOUNT_ATTR_NOSYMFOLLOW set failed: EINVAL (22)
tst_device.c:394: TWARN: umount('ot_mntpoint') failed with EINVAL
mount_setattr01.c:119: TBROK: umount(ot_mntpoint) failed: EINVAL (22)
Because we mount later than opening otfd with open_tree() but need to close otfd
before umount() we cannot depend only on labels.
Thus I suggest to have this cleanup code:
out1:
SAFE_CLOSE(otfd);
out2:
if (mount_flag)
SAFE_UMOUNT(OT_MNTPOINT);
mount_flag = 0;
If Cyril is ok with this I'd merge it before release.
(I tested it on various systems, found only this issue.)
Kind regards,
Petr
+++ testcases/kernel/syscalls/mount_setattr/mount_setattr01.c
@@ -115,8 +115,10 @@ static void run(unsigned int n)
out1:
SAFE_CLOSE(otfd);
out2:
+ if (mount_flag)
+ SAFE_UMOUNT(OT_MNTPOINT);
+
mount_flag = 0;
- SAFE_UMOUNT(OT_MNTPOINT);
}
static struct tst_test test = {
--
Mailing list info: https://lists.linux.it/listinfo/ltp
next prev parent reply other threads:[~2022-05-18 8:51 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-28 10:46 [LTP] [PATCH v5] syscalls/mount_setattr01: Add basic functional test Chen Hanxiao
2022-04-28 12:24 ` Petr Vorel
2022-05-09 9:37 ` [LTP] 回复: " chenhx.fnst
2022-05-18 8:50 ` Petr Vorel [this message]
2022-05-18 14:16 ` [LTP] " xuyang2018.jy
2022-05-18 15:42 ` Petr Vorel
2022-05-27 10:36 ` Petr Vorel
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=YoSzazXY+BRhAPmc@pevik \
--to=pvorel@suse.cz \
--cc=chenhx.fnst@fujitsu.com \
--cc=ltp@lists.linux.it \
/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.