lsblk: read firmware revision from udev
This supports more device types like NVMEs. Signed-off-by: Milan Broz <gmazyland@gmail.com>
This commit is contained in:
parent
0dfba752af
commit
8e89dd8bac
3 changed files with 13 additions and 2 deletions
|
@ -38,6 +38,7 @@ void lsblk_device_free_properties(struct lsblk_devprop *p)
|
|||
free(p->model);
|
||||
free(p->partflags);
|
||||
free(p->idlink);
|
||||
free(p->revision);
|
||||
|
||||
free(p->mode);
|
||||
free(p->owner);
|
||||
|
@ -130,6 +131,9 @@ static struct lsblk_devprop *get_properties_by_udev(struct lsblk_device *ld)
|
|||
normalize_whitespace((unsigned char *) prop->serial);
|
||||
}
|
||||
|
||||
if ((data = udev_device_get_property_value(dev, "ID_REVISION")))
|
||||
prop->revision = xstrdup(data);
|
||||
|
||||
if ((data = udev_device_get_property_value(dev, "ID_MODEL_ENC"))) {
|
||||
prop->model = xstrdup(data);
|
||||
unhexmangle_string(prop->model);
|
||||
|
@ -254,6 +258,7 @@ static struct lsblk_devprop *get_properties_by_file(struct lsblk_device *ld)
|
|||
else if (lookup(buf, "ID_SCSI_SERIAL", &prop->serial)) ;
|
||||
else if (lookup(buf, "ID_SERIAL_SHORT", &prop->serial)) ;
|
||||
else if (lookup(buf, "ID_SERIAL", &prop->serial)) ;
|
||||
else if (lookup(buf, "ID_REVISION", &prop->revision)) ;
|
||||
|
||||
/* lsblk specific */
|
||||
else if (lookup(buf, "MODE", &prop->mode)) ;
|
||||
|
|
|
@ -1013,8 +1013,13 @@ static char *device_get_data(
|
|||
}
|
||||
break;
|
||||
case COL_REV:
|
||||
if (!device_is_partition(dev) && dev->nslaves == 0)
|
||||
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)
|
||||
|
|
|
@ -79,6 +79,7 @@ struct lsblk_devprop {
|
|||
char *serial; /* disk serial number */
|
||||
char *model; /* disk model */
|
||||
char *idlink; /* /dev/disk/by-id/<name> */
|
||||
char *revision; /* firmware revision/version */
|
||||
|
||||
/* lsblk specific (for --sysroot only) */
|
||||
char *owner; /* user name */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue