summaryrefslogtreecommitdiffstats
path: root/misc-utils/lsblk.h
diff options
context:
space:
mode:
authorKarel Zak2018-10-18 15:46:07 +0200
committerKarel Zak2018-12-07 12:33:34 +0100
commitdc4662f0e755929de9cbe98b1b343b492fd620f4 (patch)
tree6947fd4b81219649cb23eff5d1eb4b12f3c86252 /misc-utils/lsblk.h
parentlsblk: remember whole-disk, remove unused struct member (diff)
downloadkernel-qcow2-util-linux-dc4662f0e755929de9cbe98b1b343b492fd620f4.tar.gz
kernel-qcow2-util-linux-dc4662f0e755929de9cbe98b1b343b492fd620f4.tar.xz
kernel-qcow2-util-linux-dc4662f0e755929de9cbe98b1b343b492fd620f4.zip
lsblk: add --dedup <column>
The target use-case are systems with large number of multi-path devices or systems with duplicate (copied) filesystems. The feature is flexible enough to use arbitrary column (for example WWM or UUID, ...) as de-duplication key. For example tree with multi-path devices sd{c,d,e,f} ./lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 223.6G 0 disk ├─sda1 8:1 0 200M 0 part /boot/efi ├─sda2 8:2 0 200M 0 part /boot ├─sda3 8:3 0 130.3G 0 part ├─sda4 8:4 0 50G 0 part / └─sda5 8:5 0 42.9G 0 part sdb 8:16 0 74.5G 0 disk └─sdb1 8:17 0 74.5G 0 part /home/archive sdc 8:32 0 100M 0 disk └─mpatha 253:0 0 100M 0 mpath ├─mpatha1 253:1 0 50M 0 part └─mpatha2 253:2 0 49M 0 part sdd 8:48 0 100M 0 disk └─mpatha 253:0 0 100M 0 mpath ├─mpatha1 253:1 0 50M 0 part └─mpatha2 253:2 0 49M 0 part sde 8:64 0 100M 0 disk └─mpatha 253:0 0 100M 0 mpath ├─mpatha1 253:1 0 50M 0 part └─mpatha2 253:2 0 49M 0 part sdf 8:80 0 100M 0 disk └─mpatha 253:0 0 100M 0 mpath ├─mpatha1 253:1 0 50M 0 part └─mpatha2 253:2 0 49M 0 part De-duplicate by WWN: ./lsblk -M WWN NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 223.6G 0 disk ├─sda1 8:1 0 200M 0 part /boot/efi ├─sda2 8:2 0 200M 0 part /boot ├─sda3 8:3 0 130.3G 0 part ├─sda4 8:4 0 50G 0 part / └─sda5 8:5 0 42.9G 0 part sdb 8:16 0 74.5G 0 disk └─sdb1 8:17 0 74.5G 0 part /home/archive sdc 8:32 0 100M 0 disk └─mpatha 253:0 0 100M 0 mpath ├─mpatha1 253:1 0 50M 0 part └─mpatha2 253:2 0 49M 0 part Addresses: https://github.com/karelzak/util-linux/issues/616 Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'misc-utils/lsblk.h')
-rw-r--r--misc-utils/lsblk.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/misc-utils/lsblk.h b/misc-utils/lsblk.h
index 6a2ad6aa2..236c84934 100644
--- a/misc-utils/lsblk.h
+++ b/misc-utils/lsblk.h
@@ -32,9 +32,12 @@ UL_DEBUG_DECLARE_MASK(lsblk);
struct lsblk {
struct libscols_table *table; /* output table */
+
struct libscols_column *sort_col;/* sort output by this column */
int sort_id;
+ int dedup_id;
+
const char *sysroot;
int flags; /* LSBLK_* */
@@ -45,6 +48,7 @@ struct lsblk {
unsigned int scsi:1; /* print only device with HCTL (SCSI) */
unsigned int paths:1; /* print devnames with "/dev" prefix */
unsigned int sort_hidden:1; /* sort column not between output columns */
+ unsigned int dedup_hidden :1; /* deduplication column not between output columns */
unsigned int force_tree_order:1;/* sort lines by parent->tree relation */
};
@@ -91,6 +95,7 @@ struct lsblk_device {
char *dm_name; /* DM name (dm/block) */
char *filename; /* path to device node */
+ char *dedupkey; /* de-duplication key */
struct path_cxt *sysfs;
@@ -200,5 +205,6 @@ int lsblk_devtree_next_device(struct lsblk_devtree *tr,
int lsblk_devtree_has_device(struct lsblk_devtree *tr, struct lsblk_device *dev);
struct lsblk_device *lsblk_devtree_get_device(struct lsblk_devtree *tr, const char *name);
int lsblk_devtree_remove_device(struct lsblk_devtree *tr, struct lsblk_device *dev);
+int lsblk_devtree_deduplicate_devices(struct lsblk_devtree *tr);
#endif /* UTIL_LINUX_LSBLK_H */