* [LTP] [PATCH 1/2] syscalls/fspick: Set .mount_device to get rid of mounting related code @ 2020-03-23 7:11 Viresh Kumar 2020-03-23 7:11 ` [LTP] [PATCH 2/2] syscalls/open_tree: " Viresh Kumar 0 siblings, 1 reply; 3+ messages in thread From: Viresh Kumar @ 2020-03-23 7:11 UTC (permalink / raw) To: ltp We don't necessarily need to work with the fsmount() related syscalls to initially mount the device, we can set .mount_device instead and get rid of a lot of code. Suggested-by: Cyril Hrubis <chrubis@suse.cz> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> --- testcases/kernel/syscalls/fspick/fspick.h | 60 --------------------- testcases/kernel/syscalls/fspick/fspick01.c | 7 ++- testcases/kernel/syscalls/fspick/fspick02.c | 8 +-- 3 files changed, 7 insertions(+), 68 deletions(-) delete mode 100644 testcases/kernel/syscalls/fspick/fspick.h diff --git a/testcases/kernel/syscalls/fspick/fspick.h b/testcases/kernel/syscalls/fspick/fspick.h deleted file mode 100644 index 4be296ee79da..000000000000 --- a/testcases/kernel/syscalls/fspick/fspick.h +++ /dev/null @@ -1,60 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-or-later -/* - * Copyright (c) 2020 Viresh Kumar <viresh.kumar@linaro.org> - */ - -#ifndef FSPICK_H__ -#define FSPICK_H__ - -#define MNTPOINT "mntpoint" - -static int ismounted; - -static void cleanup(void) -{ - if (ismounted) - SAFE_UMOUNT(MNTPOINT); -} - -static void setup(void) -{ - int fd, fsmfd; - - fsopen_supported_by_kernel(); - - TEST(fd = fsopen(tst_device->fs_type, 0)); - if (fd == -1) - tst_brk(TBROK | TERRNO, "fsopen() failed"); - - TEST(fsconfig(fd, FSCONFIG_SET_STRING, "source", tst_device->dev, 0)); - if (TST_RET == -1) { - SAFE_CLOSE(fd); - tst_brk(TBROK | TERRNO, "fsconfig(FSCONFIG_SET_STRING) failed"); - } - - TEST(fsconfig(fd, FSCONFIG_CMD_CREATE, NULL, NULL, 0)); - if (TST_RET == -1) { - SAFE_CLOSE(fd); - tst_brk(TBROK | TERRNO, "fsconfig(FSCONFIG_CMD_CREATE) failed"); - } - - TEST(fsmfd = fsmount(fd, 0, 0)); - SAFE_CLOSE(fd); - - if (fsmfd == -1) - tst_brk(TBROK | TERRNO, "fsmount() failed"); - - TEST(move_mount(fsmfd, "", AT_FDCWD, MNTPOINT, - MOVE_MOUNT_F_EMPTY_PATH)); - SAFE_CLOSE(fsmfd); - - if (TST_RET == -1) - tst_brk(TBROK | TERRNO, "move_mount() failed"); - - if (!tst_is_mounted_at_tmpdir(MNTPOINT)) - tst_brk(TBROK | TERRNO, "device not mounted"); - - ismounted = 1; -} - -#endif /* FSPICK_H__ */ diff --git a/testcases/kernel/syscalls/fspick/fspick01.c b/testcases/kernel/syscalls/fspick/fspick01.c index c84723805cb9..2f372f7f126c 100644 --- a/testcases/kernel/syscalls/fspick/fspick01.c +++ b/testcases/kernel/syscalls/fspick/fspick01.c @@ -6,8 +6,8 @@ */ #include "tst_test.h" #include "lapi/fsmount.h" -#include "fspick.h" +#define MNTPOINT "mntpoint" #define TCASE_ENTRY(_flags) {.name = "Flag " #_flags, .flags = _flags} static struct tcase { @@ -58,10 +58,9 @@ static void run(unsigned int n) static struct tst_test test = { .tcnt = ARRAY_SIZE(tcases), .test = run, - .setup = setup, - .cleanup = cleanup, + .setup = fsopen_supported_by_kernel, .needs_root = 1, - .format_device = 1, + .mount_device = 1, .mntpoint = MNTPOINT, .all_filesystems = 1, .dev_fs_flags = TST_FS_SKIP_FUSE, diff --git a/testcases/kernel/syscalls/fspick/fspick02.c b/testcases/kernel/syscalls/fspick/fspick02.c index dc8f153ccc48..b9d020226856 100644 --- a/testcases/kernel/syscalls/fspick/fspick02.c +++ b/testcases/kernel/syscalls/fspick/fspick02.c @@ -6,7 +6,8 @@ */ #include "tst_test.h" #include "lapi/fsmount.h" -#include "fspick.h" + +#define MNTPOINT "mntpoint" static struct tcase { char *name; @@ -44,10 +45,9 @@ static void run(unsigned int n) static struct tst_test test = { .tcnt = ARRAY_SIZE(tcases), .test = run, - .setup = setup, - .cleanup = cleanup, + .setup = fsopen_supported_by_kernel, .needs_root = 1, - .format_device = 1, + .mount_device = 1, .mntpoint = MNTPOINT, .all_filesystems = 1, .dev_fs_flags = TST_FS_SKIP_FUSE, -- 2.21.0.rc0.269.g1a574e7a288b ^ permalink raw reply related [flat|nested] 3+ messages in thread
* [LTP] [PATCH 2/2] syscalls/open_tree: Set .mount_device to get rid of mounting related code 2020-03-23 7:11 [LTP] [PATCH 1/2] syscalls/fspick: Set .mount_device to get rid of mounting related code Viresh Kumar @ 2020-03-23 7:11 ` Viresh Kumar 2020-03-23 15:36 ` Petr Vorel 0 siblings, 1 reply; 3+ messages in thread From: Viresh Kumar @ 2020-03-23 7:11 UTC (permalink / raw) To: ltp We don't necessarily need to work with the fsmount() related syscalls to initially mount the device, we can set .mount_device instead and get rid of a lot of code. Suggested-by: Cyril Hrubis <chrubis@suse.cz> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> --- .../kernel/syscalls/open_tree/open_tree01.c | 53 ++---------------- .../kernel/syscalls/open_tree/open_tree02.c | 54 +------------------ 2 files changed, 6 insertions(+), 101 deletions(-) diff --git a/testcases/kernel/syscalls/open_tree/open_tree01.c b/testcases/kernel/syscalls/open_tree/open_tree01.c index ddaabed810bd..f217866bbb2b 100644 --- a/testcases/kernel/syscalls/open_tree/open_tree01.c +++ b/testcases/kernel/syscalls/open_tree/open_tree01.c @@ -38,54 +38,12 @@ static void setup(void) static void run(unsigned int n) { struct tcase *tc = &tcases[n]; - int fd, fsmfd, otfd; - - TEST(fd = fsopen(tst_device->fs_type, 0)); - if (fd == -1) { - tst_res(TFAIL | TTERRNO, "fsopen() failed"); - return; - } - - TEST(fsconfig(fd, FSCONFIG_SET_STRING, "source", tst_device->dev, 0)); - if (TST_RET == -1) { - SAFE_CLOSE(fd); - tst_res(TFAIL | TTERRNO, "fsconfig(FSCONFIG_SET_STRING) failed"); - return; - } - - TEST(fsconfig(fd, FSCONFIG_CMD_CREATE, NULL, NULL, 0)); - if (TST_RET == -1) { - SAFE_CLOSE(fd); - tst_res(TFAIL | TTERRNO, "fsconfig(FSCONFIG_CMD_CREATE) failed"); - return; - } - - TEST(fsmfd = fsmount(fd, 0, 0)); - SAFE_CLOSE(fd); - - if (fsmfd == -1) { - tst_res(TFAIL | TTERRNO, "fsmount() failed"); - return; - } - - TEST(move_mount(fsmfd, "", AT_FDCWD, MNTPOINT, - MOVE_MOUNT_F_EMPTY_PATH)); - SAFE_CLOSE(fsmfd); - - if (TST_RET == -1) { - tst_res(TFAIL | TTERRNO, "move_mount() failed"); - return; - } - - if (!tst_is_mounted_at_tmpdir(MNTPOINT)) { - tst_res(TFAIL | TTERRNO, "device not mounted"); - return; - } + int otfd; TEST(otfd = open_tree(AT_FDCWD, MNTPOINT, tc->flags | OPEN_TREE_CLONE)); if (otfd == -1) { tst_res(TFAIL | TTERRNO, "open_tree() failed"); - goto out; + return; } TEST(move_mount(otfd, "", AT_FDCWD, OT_MNTPOINT, @@ -94,16 +52,13 @@ static void run(unsigned int n) if (TST_RET == -1) { tst_res(TFAIL | TTERRNO, "move_mount() failed"); - goto out; + return; } if (tst_is_mounted_at_tmpdir(OT_MNTPOINT)) { SAFE_UMOUNT(OT_MNTPOINT); tst_res(TPASS, "%s: open_tree() passed", tc->name); } - -out: - SAFE_UMOUNT(MNTPOINT); } static struct tst_test test = { @@ -112,7 +67,7 @@ static struct tst_test test = { .setup = setup, .cleanup = cleanup, .needs_root = 1, - .format_device = 1, + .mount_device = 1, .mntpoint = MNTPOINT, .all_filesystems = 1, .dev_fs_flags = TST_FS_SKIP_FUSE, diff --git a/testcases/kernel/syscalls/open_tree/open_tree02.c b/testcases/kernel/syscalls/open_tree/open_tree02.c index 76a750ae412b..32ad1aefe556 100644 --- a/testcases/kernel/syscalls/open_tree/open_tree02.c +++ b/testcases/kernel/syscalls/open_tree/open_tree02.c @@ -21,55 +21,6 @@ static struct tcase { {"invalid-flags", AT_FDCWD, MNTPOINT, 0xFFFFFFFF, EINVAL}, }; -static int ismounted; - -static void cleanup(void) -{ - if (ismounted) - SAFE_UMOUNT(MNTPOINT); -} - -static void setup(void) -{ - int fd, fsmfd; - - fsopen_supported_by_kernel(); - - TEST(fd = fsopen(tst_device->fs_type, 0)); - if (fd == -1) - tst_brk(TBROK | TTERRNO, "fsopen() failed"); - - TEST(fsconfig(fd, FSCONFIG_SET_STRING, "source", tst_device->dev, 0)); - if (TST_RET == -1) { - SAFE_CLOSE(fd); - tst_brk(TBROK | TTERRNO, "fsconfig(FSCONFIG_SET_STRING) failed"); - } - - TEST(fsconfig(fd, FSCONFIG_CMD_CREATE, NULL, NULL, 0)); - if (TST_RET == -1) { - SAFE_CLOSE(fd); - tst_brk(TBROK | TTERRNO, "fsconfig(FSCONFIG_CMD_CREATE) failed"); - } - - TEST(fsmfd = fsmount(fd, 0, 0)); - SAFE_CLOSE(fd); - - if (fsmfd == -1) - tst_brk(TBROK | TTERRNO, "fsmount() failed"); - - TEST(move_mount(fsmfd, "", AT_FDCWD, MNTPOINT, - MOVE_MOUNT_F_EMPTY_PATH)); - SAFE_CLOSE(fsmfd); - - if (TST_RET == -1) - tst_brk(TBROK | TTERRNO, "move_mount() failed"); - - if (!tst_is_mounted_at_tmpdir(MNTPOINT)) - tst_brk(TBROK | TTERRNO, "device not mounted"); - - ismounted = 1; -} - static void run(unsigned int n) { struct tcase *tc = &tcases[n]; @@ -95,10 +46,9 @@ static void run(unsigned int n) static struct tst_test test = { .tcnt = ARRAY_SIZE(tcases), .test = run, - .setup = setup, - .cleanup = cleanup, + .setup = fsopen_supported_by_kernel, .needs_root = 1, - .format_device = 1, + .mount_device = 1, .mntpoint = MNTPOINT, .all_filesystems = 1, .dev_fs_flags = TST_FS_SKIP_FUSE, -- 2.21.0.rc0.269.g1a574e7a288b ^ permalink raw reply related [flat|nested] 3+ messages in thread
* [LTP] [PATCH 2/2] syscalls/open_tree: Set .mount_device to get rid of mounting related code 2020-03-23 7:11 ` [LTP] [PATCH 2/2] syscalls/open_tree: " Viresh Kumar @ 2020-03-23 15:36 ` Petr Vorel 0 siblings, 0 replies; 3+ messages in thread From: Petr Vorel @ 2020-03-23 15:36 UTC (permalink / raw) To: ltp Hi Viresh, > We don't necessarily need to work with the fsmount() related syscalls to > initially mount the device, we can set .mount_device instead and get rid > of a lot of code. Patchset merged. Thanks! Kind regards, Petr ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-03-23 15:36 UTC | newest] Thread overview: 3+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2020-03-23 7:11 [LTP] [PATCH 1/2] syscalls/fspick: Set .mount_device to get rid of mounting related code Viresh Kumar 2020-03-23 7:11 ` [LTP] [PATCH 2/2] syscalls/open_tree: " Viresh Kumar 2020-03-23 15:36 ` Petr Vorel
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox