[LTP] [PATCH 5/6] tst_device: Add support -f filesystem
Petr Vorel
pvorel@suse.cz
Sat Aug 27 02:28:14 CEST 2022
Useful to get smaller minimal required size.
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
testcases/lib/tst_device.c | 18 +++++++++++++-----
1 file changed, 13 insertions(+), 5 deletions(-)
diff --git a/testcases/lib/tst_device.c b/testcases/lib/tst_device.c
index b672202e2..a161fb069 100644
--- a/testcases/lib/tst_device.c
+++ b/testcases/lib/tst_device.c
@@ -19,19 +19,19 @@ static struct tst_test test = {
static void print_help(void)
{
fprintf(stderr, "\nUsage:\n");
- fprintf(stderr, "tst_device [-s size [-d /path/to/device]] acquire\n");
+ fprintf(stderr, "tst_device [-f filesystem] [-s size [-d /path/to/device]] acquire\n");
fprintf(stderr, "tst_device -d /path/to/device release\n");
fprintf(stderr, "tst_device -h\n\n");
}
-static int acquire_device(const char *device_path, unsigned int size)
+static int acquire_device(const char *device_path, unsigned int size, long f_type)
{
const char *device;
if (device_path)
device = tst_acquire_loop_device(size, device_path);
else
- device = tst_acquire_device__(size, TST_ALL_FILESYSTEMS);
+ device = tst_acquire_device__(size, f_type);
if (!device)
return 1;
@@ -66,6 +66,7 @@ int main(int argc, char *argv[])
{
char *device_path = NULL;
unsigned int size = 0;
+ long f_type = TST_ALL_FILESYSTEMS;
int ret;
/*
@@ -79,7 +80,7 @@ int main(int argc, char *argv[])
*/
tst_test = &test;
- while ((ret = getopt(argc, argv, "d:hs:"))) {
+ while ((ret = getopt(argc, argv, "d:f:hs:"))) {
if (ret < 0)
break;
@@ -87,6 +88,13 @@ int main(int argc, char *argv[])
case 'd':
device_path = optarg;
break;
+ case 'f':
+ f_type = tst_fs_name_type(optarg);
+ if (f_type == -1) {
+ fprintf(stderr, "ERROR: Unsupported filesystem '%s'", optarg);
+ return 1;
+ }
+ break;
case 'h':
print_help();
return 0;
@@ -104,7 +112,7 @@ int main(int argc, char *argv[])
goto help;
if (!strcmp(argv[optind], "acquire")) {
- if (acquire_device(device_path, size))
+ if (acquire_device(device_path, size, f_type))
goto help;
} else if (!strcmp(argv[optind], "release")) {
if (release_device(device_path))
--
2.37.2
More information about the ltp
mailing list