|
|
d2bdca |
diff -up util-linux-2.23.2/misc-utils/lsblk.c.kzak util-linux-2.23.2/misc-utils/lsblk.c
|
|
|
d2bdca |
--- util-linux-2.23.2/misc-utils/lsblk.c.kzak 2015-06-25 11:01:10.543344225 +0200
|
|
|
d2bdca |
+++ util-linux-2.23.2/misc-utils/lsblk.c 2015-06-25 11:14:17.085404974 +0200
|
|
|
d2bdca |
@@ -953,11 +953,13 @@ static void set_tt_data(struct blkdev_cx
|
|
|
d2bdca |
};
|
|
|
d2bdca |
}
|
|
|
d2bdca |
|
|
|
d2bdca |
-static void print_device(struct blkdev_cxt *cxt, struct tt_line *tt_parent)
|
|
|
d2bdca |
+static void fill_table_line(struct blkdev_cxt *cxt, struct tt_line *tt_parent)
|
|
|
d2bdca |
{
|
|
|
d2bdca |
int i;
|
|
|
d2bdca |
|
|
|
d2bdca |
cxt->tt_line = tt_add_line(lsblk->tt, tt_parent);
|
|
|
d2bdca |
+ if (!cxt->tt_line)
|
|
|
d2bdca |
+ return;
|
|
|
d2bdca |
|
|
|
d2bdca |
for (i = 0; i < ncolumns; i++)
|
|
|
d2bdca |
set_tt_data(cxt, i, get_column_id(i), cxt->tt_line);
|
|
|
d2bdca |
@@ -1084,7 +1086,7 @@ static int list_partitions(struct blkdev
|
|
|
d2bdca |
goto next;
|
|
|
d2bdca |
|
|
|
d2bdca |
wholedisk_cxt->parent = &part_cxt;
|
|
|
d2bdca |
- print_device(&part_cxt, parent_cxt ? parent_cxt->tt_line : NULL);
|
|
|
d2bdca |
+ fill_table_line(&part_cxt, parent_cxt ? parent_cxt->tt_line : NULL);
|
|
|
d2bdca |
if (!lsblk->nodeps)
|
|
|
d2bdca |
process_blkdev(wholedisk_cxt, &part_cxt, 0, NULL);
|
|
|
d2bdca |
} else {
|
|
|
d2bdca |
@@ -1098,7 +1100,7 @@ static int list_partitions(struct blkdev
|
|
|
d2bdca |
|
|
|
d2bdca |
/* Print whole disk only once */
|
|
|
d2bdca |
if (r)
|
|
|
d2bdca |
- print_device(wholedisk_cxt, parent_cxt ? parent_cxt->tt_line : NULL);
|
|
|
d2bdca |
+ fill_table_line(wholedisk_cxt, parent_cxt ? parent_cxt->tt_line : NULL);
|
|
|
d2bdca |
if (ps == 0 && !lsblk->nodeps)
|
|
|
d2bdca |
process_blkdev(&part_cxt, wholedisk_cxt, 0, NULL);
|
|
|
d2bdca |
}
|
|
|
d2bdca |
@@ -1171,9 +1173,11 @@ static int list_deps(struct blkdev_cxt *
|
|
|
d2bdca |
process_blkdev(&dep, cxt, 1, d->d_name);
|
|
|
d2bdca |
}
|
|
|
d2bdca |
/* The dependency is a whole device. */
|
|
|
d2bdca |
- else if (!set_cxt(&dep, cxt, NULL, d->d_name))
|
|
|
d2bdca |
- process_blkdev(&dep, cxt, 1, NULL);
|
|
|
d2bdca |
-
|
|
|
d2bdca |
+ else if (!set_cxt(&dep, cxt, NULL, d->d_name)) {
|
|
|
d2bdca |
+ /* For inverse tree we don't want to show partitions
|
|
|
d2bdca |
+ * if the dependence is pn whle-disk */
|
|
|
d2bdca |
+ process_blkdev(&dep, cxt, lsblk->inverse ? 0 : 1, NULL);
|
|
|
d2bdca |
+ }
|
|
|
d2bdca |
reset_blkdev_cxt(&dep;;
|
|
|
d2bdca |
}
|
|
|
d2bdca |
closedir(dir);
|
|
|
d2bdca |
@@ -1185,9 +1189,10 @@ static int process_blkdev(struct blkdev_
|
|
|
d2bdca |
int do_partitions, const char *part_name)
|
|
|
d2bdca |
{
|
|
|
d2bdca |
if (do_partitions && cxt->npartitions)
|
|
|
d2bdca |
- return list_partitions(cxt, parent, part_name);
|
|
|
d2bdca |
+ list_partitions(cxt, parent, part_name); /* partitoins + whole-disk */
|
|
|
d2bdca |
+ else
|
|
|
d2bdca |
+ fill_table_line(cxt, parent ? parent->tt_line : NULL); /* whole-disk only */
|
|
|
d2bdca |
|
|
|
d2bdca |
- print_device(cxt, parent ? parent->tt_line : NULL);
|
|
|
d2bdca |
return list_deps(cxt);
|
|
|
d2bdca |
}
|
|
|
d2bdca |
|