All of lore.kernel.org
 help / color / mirror / Atom feed
From: Cyril Hrubis <chrubis@suse.cz>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH] lib/tst_supported_fs_types.c: Add tmpfs to filesystem whitelist
Date: Fri, 26 Feb 2021 10:54:52 +0100	[thread overview]
Message-ID: <YDjFbG0In5oQjLKN@yuki.lan> (raw)
In-Reply-To: <20210226090615.231970-1-zhaogongyi@huawei.com>

Hi!
> diff --git a/lib/tst_supported_fs_types.c b/lib/tst_supported_fs_types.c
> index 00ede549d..696b6731e 100644
> --- a/lib/tst_supported_fs_types.c
> +++ b/lib/tst_supported_fs_types.c
> @@ -22,6 +22,7 @@ static const char *const fs_type_whitelist[] = {
>  	"vfat",
>  	"exfat",
>  	"ntfs",
> +	"tmpfs",
>  	NULL
>  };
> 
> @@ -34,6 +35,10 @@ static int has_mkfs(const char *fs_type)
> 
>  	sprintf(buf, "mkfs.%s >/dev/null 2>&1", fs_type);
> 
> +	if (strstr(buf, "mkfs.tmpfs")) {
> +		return 1;
> +	}
> +
>  	ret = tst_system(buf);
> 
>  	if (WEXITSTATUS(ret) == 127) {
> @@ -55,8 +60,8 @@ static int has_kernel_support(const char *fs_type, int flags)
>  	if (!tmpdir)
>  		tmpdir = "/tmp";
> 
> -	mount("/dev/zero", tmpdir, fs_type, 0, NULL);
> -	if (errno != ENODEV) {
> +	ret = mount("/dev/zero", tmpdir, fs_type, 0, NULL);

The manual page explicitly says that errno is set to ENODEV if
filesystem is not supported by kernel. So the check for errno should
stay, since the statement above will fail to mount any real filesystem
since we pass "/dev/zero" instead of valid filesystem image there.

I.e. if we pass a real filesystem there it will either fail with EINVAL
(since /dev/zero does not have a valid superblock) or ENODEV if there is
no kernel driver for the filesystem.

> +	if (!ret) {

I guess that tmpfs succeeds to mount there. So I guess that we should
change the condition to:

	if ((ret && errno != ENODEV) || !ret) {
		if (!ret)
			tst_umount(tmpdir);

		tst_res(TINFO, "Kernel supports %s", fs_type);
		return 1;
	}


But there is another problem there, since the code still mounts tmpfs on
tmpdir for a short while, which is temporary directory used by all LTP
tests, which may potentially break tests that runs in parallel.

So we will have to prepare a temporary directory with mkdtemp() under
the tmpdir as well and pass that to the mount() syscall instead.

-- 
Cyril Hrubis
chrubis@suse.cz

  reply	other threads:[~2021-02-26  9:54 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-26  9:06 [LTP] [PATCH] lib/tst_supported_fs_types.c: Add tmpfs to filesystem whitelist Zhao Gongyi
2021-02-26  9:54 ` Cyril Hrubis [this message]
2021-02-27  9:33 zhaogongyi
2021-03-02 10:43 ` Cyril Hrubis
2021-03-04  2:08 Zhao Gongyi
2021-03-08 16:11 ` Cyril Hrubis
2021-03-04  2:14 zhaogongyi
2021-03-09 13:01 Zhao Gongyi
2021-03-10 12:29 ` Cyril Hrubis
2021-03-12 10:46 ` Petr Vorel
2021-04-13 17:28 ` Cyril Hrubis
2021-03-09 13:08 zhaogongyi

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=YDjFbG0In5oQjLKN@yuki.lan \
    --to=chrubis@suse.cz \
    --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.