1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3 * Copyright (c) 2018 FUJITSU LIMITED. All rights reserved.
4 * Author: Xiao Yang <yangx.jy@cn.fujitsu.com>
5 */
6
7 #include <stdio.h>
8 #include <string.h>
9
10 #define TST_NO_DEFAULT_MAIN
11 #include "tst_test.h"
12 #include "tst_fs.h"
13
usage(void)14 static void usage(void)
15 {
16 fprintf(stderr, "Usage: tst_supported_fs [fs_type]\n");
17 fprintf(stderr, " If fs_type is supported, return 0\n");
18 fprintf(stderr, " If fs_type isn't supported, return 1\n");
19 fprintf(stderr, " If fs_type isn't specified, print the list of supported filesystems\n");
20 fprintf(stderr, " fs_type - a specified filesystem type\n");
21 }
22
main(int argc,char * argv[])23 int main(int argc, char *argv[])
24 {
25 const char *const *filesystems;
26 int i;
27
28 if (argc > 2) {
29 fprintf(stderr, "Can't specify multiple fs_type\n");
30 usage();
31 return 2;
32 }
33
34 if (argv[1] && !strcmp(argv[1], "-h")) {
35 usage();
36 return 0;
37 }
38
39 if (argv[1])
40 return !tst_fs_is_supported(argv[1], 0);
41
42 filesystems = tst_get_supported_fs_types(0);
43 for (i = 0; filesystems[i]; i++)
44 printf("%s\n", filesystems[i]);
45
46 return 0;
47 }
48