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