]> git.ipfire.org Git - thirdparty/util-linux.git/blobdiff - misc-utils/findmnt.c
fincore: remove unused variable [clang scan]
[thirdparty/util-linux.git] / misc-utils / findmnt.c
index 4d55cde33d2f1314d2b29497774e54f2ee9a85db..eea772f0e6d5cf228b301ec3b50b0e6fd0cc828e 100644 (file)
@@ -947,6 +947,12 @@ static int match_func(struct libmnt_fs *fs,
                        return rc;
        }
 
+       if ((flags & FL_REAL) && mnt_fs_is_pseudofs(fs))
+           return rc;
+
+       if ((flags & FL_PSEUDO) && !mnt_fs_is_pseudofs(fs))
+           return rc;
+
        return !rc;
 }
 
@@ -1227,9 +1233,12 @@ static void __attribute__((__noreturn__)) usage(void)
        fputs(_(" -n, --noheadings       don't print column headings\n"), out);
        fputs(_(" -O, --options <list>   limit the set of filesystems by mount options\n"), out);
        fputs(_(" -o, --output <list>    the output columns to be shown\n"), out);
+       fputs(_("     --output-all       output all available columns\n"), out);
        fputs(_(" -P, --pairs            use key=\"value\" output format\n"), out);
+       fputs(_("     --pseudo           print only pseudo-filesystems\n"), out);
        fputs(_(" -R, --submounts        print all submounts for the matching filesystems\n"), out);
        fputs(_(" -r, --raw              use raw output format\n"), out);
+       fputs(_("     --real             print only real filesystems\n"), out);
        fputs(_(" -S, --source <string>  the device to mount (by name, maj:min, \n"
                "                          LABEL=, UUID=, PARTUUID=, PARTLABEL=)\n"), out);
        fputs(_(" -T, --target <path>    the path to the filesystem to use\n"), out);
@@ -1238,7 +1247,7 @@ static void __attribute__((__noreturn__)) usage(void)
        fputs(_(" -t, --types <list>     limit the set of filesystems by FS types\n"), out);
        fputs(_(" -U, --uniq             ignore filesystems with duplicate target\n"), out);
        fputs(_(" -u, --notruncate       don't truncate text in columns\n"), out);
-       fputs(_(" -v, --nofsroot         don't print [/dir] for bind or btrfs mounts\n"), out); 
+       fputs(_(" -v, --nofsroot         don't print [/dir] for bind or btrfs mounts\n"), out);
 
        fputc('\n', out);
        fputs(_(" -x, --verify           verify mount table content (default is fstab)\n"), out);
@@ -1271,8 +1280,11 @@ int main(int argc, char *argv[])
        struct libscols_table *table = NULL;
 
        enum {
-                FINDMNT_OPT_VERBOSE = CHAR_MAX + 1,
-               FINDMNT_OPT_TREE
+               FINDMNT_OPT_VERBOSE = CHAR_MAX + 1,
+               FINDMNT_OPT_TREE,
+               FINDMNT_OPT_OUTPUT_ALL,
+               FINDMNT_OPT_PSEUDO,
+               FINDMNT_OPT_REAL
        };
 
        static const struct option longopts[] = {
@@ -1296,6 +1308,7 @@ int main(int argc, char *argv[])
                { "notruncate",     no_argument,       NULL, 'u'                 },
                { "options",        required_argument, NULL, 'O'                 },
                { "output",         required_argument, NULL, 'o'                 },
+               { "output-all",     no_argument,       NULL, FINDMNT_OPT_OUTPUT_ALL },
                { "poll",           optional_argument, NULL, 'p'                 },
                { "pairs",          no_argument,       NULL, 'P'                 },
                { "raw",            no_argument,       NULL, 'r'                 },
@@ -1313,11 +1326,13 @@ int main(int argc, char *argv[])
                { "version",        no_argument,       NULL, 'V'                 },
                { "verbose",        no_argument,       NULL, FINDMNT_OPT_VERBOSE },
                { "tree",           no_argument,       NULL, FINDMNT_OPT_TREE    },
+               { "real",           no_argument,       NULL, FINDMNT_OPT_REAL    },
+               { "pseudo",         no_argument,       NULL, FINDMNT_OPT_PSEUDO  },
                { NULL, 0, NULL, 0 }
        };
 
        static const ul_excl_t excl[] = {       /* rows and cols in ASCII order */
-               { 'C', 'c'},                    /* [no]canonicalize */
+               { 'C', 'c'},                    /* [no]canonicalize */
                { 'C', 'e' },                   /* nocanonicalize, evaluate */
                { 'J', 'P', 'r','x' },          /* json,pairs,raw,verify */
                { 'M', 'T' },                   /* mountpoint, target */
@@ -1325,6 +1340,7 @@ int main(int argc, char *argv[])
                { 'P','l','r','x' },            /* pairs,list,raw,verify */
                { 'p','x' },                    /* poll,verify */
                { 'm','p','s' },                /* mtab,poll,fstab */
+               { FINDMNT_OPT_PSEUDO, FINDMNT_OPT_REAL },
                { 0 }
        };
        int excl_st[ARRAY_SIZE(excl)] = UL_EXCL_STATUS_INIT;
@@ -1332,7 +1348,7 @@ int main(int argc, char *argv[])
        setlocale(LC_ALL, "");
        bindtextdomain(PACKAGE, LOCALEDIR);
        textdomain(PACKAGE);
-       atexit(close_stdout);
+       close_stdout_atexit();
 
        /* default output format */
        flags |= FL_TREE;
@@ -1375,9 +1391,6 @@ int main(int argc, char *argv[])
                case 'e':
                        flags |= FL_EVALUATE;
                        break;
-               case 'h':
-                       usage();
-                       break;
                case 'i':
                        flags |= FL_INVERT;
                        break;
@@ -1396,6 +1409,13 @@ int main(int argc, char *argv[])
                case 'o':
                        outarg = optarg;
                        break;
+               case FINDMNT_OPT_OUTPUT_ALL:
+                       for (ncolumns = 0; ncolumns < ARRAY_SIZE(infos); ncolumns++) {
+                               if (is_tabdiff_column(ncolumns))
+                                       continue;
+                               columns[ncolumns] = ncolumns;
+                       }
+                       break;
                case 'O':
                        set_match(COL_OPTIONS, optarg);
                        break;
@@ -1467,9 +1487,6 @@ int main(int argc, char *argv[])
                case 'w':
                        timeout = strtos32_or_err(optarg, _("invalid timeout argument"));
                        break;
-               case 'V':
-                       printf(UTIL_LINUX_VERSION);
-                       return EXIT_SUCCESS;
                case 'x':
                        verify = 1;
                        break;
@@ -1479,6 +1496,17 @@ int main(int argc, char *argv[])
                case FINDMNT_OPT_TREE:
                        force_tree = 1;
                        break;
+               case FINDMNT_OPT_PSEUDO:
+                       flags |= FL_PSEUDO;
+                       break;
+               case FINDMNT_OPT_REAL:
+                       flags |= FL_REAL;
+                       break;
+
+               case 'h':
+                       usage();
+               case 'V':
+                       print_version(EXIT_SUCCESS);
                default:
                        errtryhelp(EXIT_FAILURE);
                }