]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
misc-tools/findmnt: add --pseudo, --real filters
authorsluidfoe <sluidfoe@gmail.com>
Tue, 8 May 2018 18:08:47 +0000 (13:08 -0500)
committersluidfoe <sluidfoe@gmail.com>
Thu, 10 May 2018 16:58:30 +0000 (11:58 -0500)
misc-utils/findmnt.c
misc-utils/findmnt.h

index c3365534c517528d828d10fe8b50771923c43da7..09b98cc222cdb457106b122b363432c7e8456135 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;
 }
 
@@ -1229,8 +1235,10 @@ static void __attribute__((__noreturn__)) usage(void)
        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);
@@ -1274,7 +1282,9 @@ int main(int argc, char *argv[])
        enum {
                 FINDMNT_OPT_VERBOSE = CHAR_MAX + 1,
                FINDMNT_OPT_TREE,
-               FINDMNT_OPT_OUTPUT_ALL
+               FINDMNT_OPT_OUTPUT_ALL,
+               FINDMNT_OPT_PSEUDO,
+               FINDMNT_OPT_REAL
        };
 
        static const struct option longopts[] = {
@@ -1316,6 +1326,8 @@ 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 }
        };
 
@@ -1328,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;
@@ -1489,6 +1502,12 @@ 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;
                default:
                        errtryhelp(EXIT_FAILURE);
                }
index fbaa38e82041f73f2e4a78104bc2688f9defc657..6388837a08f9878d64c9ab2744dbf211200f4e7d 100644 (file)
@@ -18,6 +18,8 @@ enum {
        FL_NOCACHE      = (1 << 14),
        FL_STRICTTARGET = (1 << 15),
        FL_VERBOSE      = (1 << 16),
+       FL_PSEUDO       = (1 << 17),
+       FL_REAL         = (1 << 18),
 
        /* basic table settings */
        FL_ASCII        = (1 << 20),