]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lsblk: fix in-tree filtering
authorKarel Zak <kzak@redhat.com>
Mon, 25 Sep 2023 11:19:49 +0000 (13:19 +0200)
committerKarel Zak <kzak@redhat.com>
Mon, 20 Nov 2023 21:25:46 +0000 (22:25 +0100)
The function device_to_scols() is used recursively (for children).
It's impossible leave the function on filter status=false, it's
necessary to continue in the tree.

Signed-off-by: Karel Zak <kzak@redhat.com>
misc-utils/lsblk.c

index 6050cbf40aadd6c734525b57d7bbd568583319c0..eb758b170bdb85fe7ed81bf739f67d8812c93d7b 100644 (file)
@@ -1317,18 +1317,18 @@ static void device_to_scols(
                        if (x)
                                scols_line_remove_child(x, ln);
                        scols_table_remove_line(tab, ln);
-                       goto done;
+                       ln = NULL;
                }
        }
 
        /* read column specific data and set it to smartcols table line */
-       for (i = 0; i < ncolumns; i++) {
+       for (i = 0; ln && i < ncolumns; i++) {
                if (scols_line_is_filled(ln, i))
                        continue;
                device_fill_scols_cell(dev, parent, ln, i);
        }
 
-       if (link_group) {
+       if (ln && link_group) {
                struct lsblk_device *p;
                struct libscols_line *gr = parent_line;
 
@@ -1371,7 +1371,6 @@ static void device_to_scols(
                        scols_line_set_color(ln, lsblk->hlighter_seq);
        }
 
-done:
        /* Let's be careful with number of open files */
        ul_path_close_dirfd(dev->sysfs);
 }