]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
findmnt: add --shadowed
authorKarel Zak <kzak@redhat.com>
Mon, 22 Mar 2021 13:58:05 +0000 (14:58 +0100)
committerKarel Zak <kzak@redhat.com>
Mon, 22 Mar 2021 14:00:47 +0000 (15:00 +0100)
Signed-off-by: Karel Zak <kzak@redhat.com>
misc-utils/findmnt.8
misc-utils/findmnt.c
misc-utils/findmnt.h

index c93c01c20b719c4cdeefd0788cb799b634423e19..658dda9eb9a24d0ea78a15bca5379c26cc166c95 100644 (file)
@@ -193,6 +193,9 @@ available for umount and remount actions
 .B \-\-pseudo
 Print only pseudo filesystems.
 .TP
+.B \-\-shadowed
+Print only filesystems over-mounted by another filesystem.
+.TP
 .BR \-R , " \-\-submounts"
 Print recursively all submounts for the selected filesystems.  The restrictions
 defined by options \fB\-t\fP, \fB\-O\fP, \fB\-S\fP, \fB\-T\fP and
index 774c059de33901720fcfe808ea1170c338b4c433..a1c6925351d0dbbf7b64f22eeca96ba521575c7a 100644 (file)
@@ -970,6 +970,14 @@ static int match_func(struct libmnt_fs *fs,
        if ((flags & FL_PSEUDO) && !mnt_fs_is_pseudofs(fs))
            return rc;
 
+       if ((flags & FL_SHADOWED)) {
+               struct libmnt_table *tb = NULL;
+
+               mnt_fs_get_table(fs, &tb);
+               if (tb && mnt_table_over_fs(tb, fs, NULL) != 0)
+                       return rc;
+       }
+
        return !rc;
 }
 
@@ -1254,6 +1262,7 @@ static void __attribute__((__noreturn__)) usage(void)
        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(_("     --shadowed         print only filesystems over-mounted by another filesystem\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);
@@ -1304,7 +1313,8 @@ int main(int argc, char *argv[])
                FINDMNT_OPT_OUTPUT_ALL,
                FINDMNT_OPT_PSEUDO,
                FINDMNT_OPT_REAL,
-               FINDMNT_OPT_VFS_ALL
+               FINDMNT_OPT_VFS_ALL,
+               FINDMNT_OPT_SHADOWED
        };
 
        static const struct option longopts[] = {
@@ -1349,6 +1359,7 @@ int main(int argc, char *argv[])
                { "real",           no_argument,       NULL, FINDMNT_OPT_REAL    },
                { "pseudo",         no_argument,       NULL, FINDMNT_OPT_PSEUDO  },
                { "vfs-all",        no_argument,       NULL, FINDMNT_OPT_VFS_ALL },
+               { "shadowed",       no_argument,       NULL, FINDMNT_OPT_SHADOWED },
                { NULL, 0, NULL, 0 }
        };
 
@@ -1526,6 +1537,9 @@ int main(int argc, char *argv[])
                case FINDMNT_OPT_VFS_ALL:
                        flags |= FL_VFS_ALL;
                        break;
+               case FINDMNT_OPT_SHADOWED:
+                       flags |= FL_SHADOWED;
+                       break;
 
                case 'h':
                        usage();
index 92d1119ae6d4741ccebdf866ca50de0fce6a5945..ed7dea05af282876f5b4db08c1c4c74daa9574eb 100644 (file)
@@ -21,14 +21,15 @@ enum {
        FL_PSEUDO       = (1 << 17),
        FL_REAL         = (1 << 18),
        FL_VFS_ALL      = (1 << 19),
+       FL_SHADOWED     = (1 << 20),
 
        /* basic table settings */
-       FL_ASCII        = (1 << 20),
-       FL_RAW          = (1 << 21),
-       FL_NOHEADINGS   = (1 << 22),
-       FL_EXPORT       = (1 << 23),
-       FL_TREE         = (1 << 24),
-       FL_JSON         = (1 << 25),
+       FL_ASCII        = (1 << 21),
+       FL_RAW          = (1 << 22),
+       FL_NOHEADINGS   = (1 << 23),
+       FL_EXPORT       = (1 << 24),
+       FL_TREE         = (1 << 25),
+       FL_JSON         = (1 << 26),
 };
 
 extern struct libmnt_cache *cache;