Skip to content

Commit

Permalink
findmnt: improve -Q to output tree
Browse files Browse the repository at this point in the history
$ findmnt -Q 'FSTYPE=="ext4"'
TARGET         SOURCE                  FSTYPE OPTIONS
/              /dev/sda4               ext4   rw,relatime
├─/var         /dev/sda3               ext4   rw,relatime
│ └─/var/cache /dev/sda5               ext4   rw,relatime
├─/mnt/virt    /dev/sdb1               ext4   rw,relatime
└─/boot        /dev/sda2               ext4   rw,relatime

Addresses: util-linux#3090
Signed-off-by: Karel Zak <kzak@redhat.com>
  • Loading branch information
karelzak committed Aug 22, 2024
1 parent 8326c99 commit 76082d4
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions misc-utils/findmnt.c
Original file line number Diff line number Diff line change
Expand Up @@ -962,8 +962,12 @@ static int create_treenode(struct libscols_table *table, struct libmnt_table *tb

if ((findmnt->flags & FL_SUBMOUNTS) || match_func(fs, findmnt)) {
bool filtered = false;
if (has_line(table, fs))
goto leave;
line = add_line(table, fs, parent_line, findmnt, &filtered);
if (!line || filtered)
if (filtered)
line = parent_line;
else if (!line)
goto leave;
} else
line = parent_line;
Expand Down Expand Up @@ -1848,7 +1852,6 @@ int main(int argc, char *argv[])
break;
case 'Q':
findmnt.filter = new_filter(optarg);
findmnt.flags &= ~FL_TREE;
break;
case 'm': /* mtab */
tabtype = TABTYPE_MTAB;
Expand Down

0 comments on commit 76082d4

Please sign in to comment.