From: Petr Vorel <pvorel@suse.cz>
To: Jeff Moyer <jmoyer@redhat.com>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH v2 2/3] lib/tst_device.c: check for BTRFS_SUPER_MAGIC instead of device major of 0
Date: Wed, 12 Feb 2025 00:52:32 +0100 [thread overview]
Message-ID: <20250211235232.GA1992438@pevik> (raw)
In-Reply-To: <20250211214627.152634-3-jmoyer@redhat.com>
Hi Jeff,
> stat() may return a major number of 0 in st_dev for any number of
> pseudo file systems. Check for the exact file system instead. There
> should be no change in behavior with this patch.
> Signed-off-by: Jeff Moyer <jmoyer@redhat.com>
> ---
> lib/tst_device.c | 13 +++++++++----
> 1 file changed, 9 insertions(+), 4 deletions(-)
> diff --git a/lib/tst_device.c b/lib/tst_device.c
> index 70234a83c..744e08a68 100644
> --- a/lib/tst_device.c
> +++ b/lib/tst_device.c
> @@ -17,6 +17,8 @@
> #include <sys/sysmacros.h>
> #include <linux/btrfs.h>
> #include <linux/limits.h>
> +#include <sys/vfs.h>
This just includes <sys/statfs.h>, could you please use it (if it's really
needed).
> +#include <linux/magic.h>
Please don't use it. We have TST_BTRFS_MAGIC and TST_OVERLAYFS_MAGIC in
tst_fs.h. If you ask why we mirror magic it was (probably) for compatibility
with very old kernel headers.
> #include "lapi/syscalls.h"
> #include "test.h"
> #include "safe_macros.h"
> @@ -546,9 +548,6 @@ static void btrfs_get_uevent_path(char *tmp_path, char *uevent_path)
> sprintf(bdev_path,
> "/sys/fs/btrfs/%s/devices", btrfs_uuid_str);
> } else {
> - if (errno == ENOTTY)
> - tst_brkm(TBROK | TERRNO, NULL, "BTRFS ioctl failed. Is %s on a tmpfs?", tmp_path);
> -
> tst_brkm(TBROK | TERRNO, NULL, "BTRFS ioctl on %s failed.", tmp_path);
> }
> SAFE_CLOSE(NULL, fd);
> @@ -578,6 +577,7 @@ __attribute__((nonnull))
> void tst_find_backing_dev(const char *path, char *dev, size_t dev_size)
> {
> struct stat buf;
> + struct statfs fsbuf;
> char uevent_path[PATH_MAX+PATH_MAX+10]; //10 is for the static uevent path
> char dev_name[NAME_MAX];
> char tmp_path[PATH_MAX];
> @@ -595,8 +595,13 @@ void tst_find_backing_dev(const char *path, char *dev, size_t dev_size)
> dev_minor = minor(buf.st_dev);
> *dev = '\0';
> - if (dev_major == 0) {
> + if (statfs(path, &fsbuf) < 0)
> + tst_brkm(TWARN | TERRNO, NULL, "statfs() failed");
Please use SAFE_STATFS() here.
> +
> + if (fsbuf.f_type == BTRFS_SUPER_MAGIC) {
We have TST_BTRFS_MAGIC tst_fs.h.
Kind regards,
Petr
> btrfs_get_uevent_path(tmp_path, uevent_path);
> + } else if (dev_major == 0) {
> + tst_brkm(TBROK, NULL, "%s resides on an unsupported pseudo-file system.", path);
> } else {
> tst_resm(TINFO, "Use uevent strategy");
> sprintf(uevent_path,
--
Mailing list info: https://lists.linux.it/listinfo/ltp
next prev parent reply other threads:[~2025-02-11 23:52 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-11 21:42 [LTP] [PATCH v2 0/3] tst_device: add support for overlayfs Jeff Moyer
2025-02-11 21:42 ` [LTP] [PATCH v2 1/3] lib/tst_device.c: factor out btrfs-specific logic from tst_find_backing_dev Jeff Moyer
2025-02-11 23:52 ` Petr Vorel
2025-02-11 21:42 ` [LTP] [PATCH v2 2/3] lib/tst_device.c: check for BTRFS_SUPER_MAGIC instead of device major of 0 Jeff Moyer
2025-02-11 23:52 ` Petr Vorel [this message]
2025-02-12 17:05 ` Jeff Moyer
2025-02-12 20:10 ` Petr Vorel
2025-02-11 21:42 ` [LTP] [PATCH v2 3/3] tst_find_backing_dev(): add support for overlayfs Jeff Moyer
2025-02-12 0:19 ` 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=20250211235232.GA1992438@pevik \
--to=pvorel@suse.cz \
--cc=jmoyer@redhat.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox