]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lsblk: add column START for partition start offsets
authorKarel Zak <kzak@redhat.com>
Wed, 9 Jun 2021 08:57:54 +0000 (10:57 +0200)
committerKarel Zak <kzak@redhat.com>
Wed, 9 Jun 2021 08:57:54 +0000 (10:57 +0200)
Fix: https://github.com/karelzak/util-linux/issues/1340
Signed-off-by: Karel Zak <kzak@redhat.com>
misc-utils/lsblk.c

index d3b5a543cdc1d63b72eff581ff79836df6718a1b..3ee8bec10819a95e12e03fbeef79cae2657bd0b1 100644 (file)
@@ -121,7 +121,8 @@ enum {
        COL_REV,
        COL_VENDOR,
        COL_ZONED,
-       COL_DAX
+       COL_DAX,
+       COL_START
 };
 
 /* basic table settings */
@@ -217,6 +218,7 @@ static struct colinfo infos[] = {
        [COL_VENDOR] = { "VENDOR", 0.1, SCOLS_FL_TRUNC, N_("device vendor") },
        [COL_ZONED]  = { "ZONED", 0.3, 0, N_("zone model") },
        [COL_DAX]    = { "DAX", 1, SCOLS_FL_RIGHT, N_("dax-capable device"), COLTYPE_BOOL },
+       [COL_START]  = { "START", 5, SCOLS_FL_RIGHT, N_("partition start offset"), COLTYPE_NUM },
 };
 
 struct lsblk *lsblk;   /* global handler */
@@ -953,6 +955,11 @@ static char *device_get_data(
                if (sortdata)
                        *sortdata = dev->size;
                break;
+       case COL_START:
+               ul_path_read_string(dev->sysfs, &str, "start");
+               if (sortdata)
+                       str2u64(str, sortdata);
+               break;
        case COL_STATE:
                if (!device_is_partition(dev) && !dev->dm_name)
                        ul_path_read_string(dev->sysfs, &str, "device/state");