]> git.ipfire.org Git - thirdparty/util-linux.git/blobdiff - misc-utils/lsblk.c
Update email.
[thirdparty/util-linux.git] / misc-utils / lsblk.c
index 9873922187c387b4bcdbaa48bba2543b70aecf1d..99a966bdd5f25d9bd07863da20939282429d71ad 100644 (file)
@@ -2,7 +2,7 @@
  * lsblk(8) - list block devices
  *
  * Copyright (C) 2010-2018 Red Hat, Inc. All rights reserved.
- * Written by Milan Broz <mbroz@redhat.com>
+ * Written by Milan Broz <gmazyland@gmail.com>
  *            Karel Zak <kzak@redhat.com>
  *
  * This program is free software; you can redistribute it and/or modify
@@ -97,6 +97,7 @@ enum {
        COL_OWNER,
        COL_PARTFLAGS,
        COL_PARTLABEL,
+       COL_PARTN,
        COL_PARTTYPE,
        COL_PARTTYPENAME,
        COL_PARTUUID,
@@ -198,6 +199,7 @@ static struct colinfo infos[] = {
        [COL_OWNER] = { "OWNER", 0.1, SCOLS_FL_TRUNC, N_("user name"), },
        [COL_PARTFLAGS] = { "PARTFLAGS", 36,  0, N_("partition flags") },
        [COL_PARTLABEL] = { "PARTLABEL", 0.1, 0, N_("partition LABEL") },
+       [COL_PARTN] = { "PARTN", 2, SCOLS_FL_RIGHT, N_("partition number as read from the partition table"), COLTYPE_NUM },
        [COL_PARTTYPENAME]  = { "PARTTYPENAME",  0.1,  0, N_("partition type name") },
        [COL_PARTTYPE] = { "PARTTYPE", 36,  0, N_("partition type code or UUID") },
        [COL_PARTUUID] = { "PARTUUID", 36,  0, N_("partition UUID") },
@@ -219,8 +221,8 @@ static struct colinfo infos[] = {
        [COL_START] = { "START", 5, SCOLS_FL_RIGHT, N_("partition start offset"), COLTYPE_NUM },
        [COL_STATE] = { "STATE", 7, SCOLS_FL_TRUNC, N_("state of the device") },
        [COL_SUBSYS] = { "SUBSYSTEMS", 0.1, SCOLS_FL_NOEXTREMES, N_("de-duplicated chain of subsystems") },
-       [COL_TARGETS] = { "MOUNTPOINTS", 0.10, SCOLS_FL_WRAP,  N_("all locations where device is mounted") },
-       [COL_TARGET] = { "MOUNTPOINT", 0.10, SCOLS_FL_TRUNC, N_("where the device is mounted") },
+       [COL_TARGETS] = { "MOUNTPOINTS", 0.10, SCOLS_FL_WRAP | SCOLS_FL_NOEXTREMES,  N_("all locations where device is mounted") },
+       [COL_TARGET] = { "MOUNTPOINT", 0.10, SCOLS_FL_TRUNC | SCOLS_FL_NOEXTREMES, N_("where the device is mounted") },
        [COL_TRANSPORT] = { "TRAN", 6, 0, N_("device transport type") },
        [COL_TYPE] = { "TYPE", 4, 0, N_("device type") },
        [COL_UUID] = { "UUID", 36,  0, N_("filesystem UUID") },
@@ -949,6 +951,11 @@ static char *device_get_data(
                if (prop && prop->partflags)
                        str = xstrdup(prop->partflags);
                break;
+       case COL_PARTN:
+               prop = lsblk_device_get_properties(dev);
+               if (prop && prop->partn)
+                       str = xstrdup(prop->partn);
+               break;
        case COL_WWN:
                prop = lsblk_device_get_properties(dev);
                if (prop && prop->wwn)
@@ -1006,8 +1013,13 @@ static char *device_get_data(
                }
                break;
        case COL_REV:
-               if (!device_is_partition(dev) && dev->nslaves == 0)
-                       ul_path_read_string(dev->sysfs, &str, "device/rev");
+               if (!device_is_partition(dev) && dev->nslaves == 0) {
+                       prop = lsblk_device_get_properties(dev);
+                       if (prop && prop->revision)
+                               str = xstrdup(prop->revision);
+                       else
+                               ul_path_read_string(dev->sysfs, &str, "device/rev");
+               }
                break;
        case COL_VENDOR:
                if (!device_is_partition(dev) && dev->nslaves == 0)
@@ -2231,6 +2243,7 @@ int main(int argc, char *argv[])
                        add_uniq_column(COL_TYPE);
                        add_uniq_column(COL_MODEL);
                        add_uniq_column(COL_SERIAL);
+                       add_uniq_column(COL_REV);
                        add_uniq_column(COL_TRANSPORT);
                        add_uniq_column(COL_RQ_SIZE);
                        add_uniq_column(COL_MQ);