Re: [LTP] [PATCH] refluxfs: Check kernel reflink support before mount
Cyril Hrubis <[email protected]>
| Newsgroups | it.linux.lists.ltp |
|---|---|
| Message-ID | <[email protected]> |
Hi!
> Something like this?
>
> diff --git a/lib/safe_macros.c b/lib/safe_macros.c
> index f95c5fdc5..34430d018 100644
> --- a/lib/safe_macros.c
> +++ b/lib/safe_macros.c
> @@ -993,9 +993,15 @@ int safe_mount(const char *file, const int lineno, void (*cleanup_fn)(void),
> "mount.%s failed with %i", filesystemtype, rval);
> return -1;
> } else if (rval == -1) {
> - tst_brkm_(file, lineno, TBROK | TERRNO, cleanup_fn,
> - "mount(%s, %s, %s, %lu, %p) failed", source, target,
> - filesystemtype, mountflags, data);
> + if (errno == EOPNOTSUPP) {
> + tst_brkm_(file, lineno, TCONF | TERRNO, cleanup_fn,
> + "mount(%s, %s, %s, %lu, %p) failed with EOPNOTSUPP", source, target,
> + filesystemtype, mountflags, data);
> + } else {
> + tst_brkm_(file, lineno, TBROK | TERRNO, cleanup_fn,
> + "mount(%s, %s, %s, %lu, %p) failed", source, target,
> + filesystemtype, mountflags, data);
> + }
> } else {
> tst_brkm_(file, lineno, TBROK | TERRNO, cleanup_fn,
> "Invalid mount(%s, %s, %s, %lu, %p) return value %d",
> diff --git a/testcases/kernel/syscalls/file_attr/file_attr02.c b/testcases/kernel/syscalls/file_attr/file_attr02.c
> index f6625985a..28c1c7ca6 100644
> --- a/testcases/kernel/syscalls/file_attr/file_attr02.c
> +++ b/testcases/kernel/syscalls/file_attr/file_attr02.c
> @@ -45,13 +45,7 @@ static void setup(void)
> struct stat statbuf;
>
> SAFE_MKDIR(MNTPOINT, 0755);
> - TEST(mount(tst_device->dev, MNTPOINT, tst_device->fs_type, 0, NULL));
> -
> - if (TST_RET == -1 && TST_ERR == EOPNOTSUPP)
> - tst_brk(TCONF, "Kernel does not support XFS reflinks");
> -
> - if (TST_RET)
> - tst_brk(TBROK | TTERRNO, "Mount failed");
> + SAFE_MOUNT(tst_device->dev, MNTPOINT, tst_device->fs_type, 0, NULL);
>
> SAFE_STAT(MNTPOINT, &statbuf);
Yes. If we do not do this we are going to open code the check over and
over.
--
Cyril Hrubis
[email protected]
--
Mailing list info: https://lists.linux.it/listinfo/ltp