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