From: Karel Zak Date: Tue, 12 Nov 2019 12:55:55 +0000 (+0100) Subject: lsblk: add FSVER (filesystem version) column X-Git-Tag: v2.35-rc1~58 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9cca1ef2d5283a461c3a6d9aa1a036bb4ada6e70;p=thirdparty%2Futil-linux.git lsblk: add FSVER (filesystem version) column Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1764523 Signed-off-by: Karel Zak --- diff --git a/misc-utils/lsblk-properties.c b/misc-utils/lsblk-properties.c index a4fdeb5bd9..a1aa695312 100644 --- a/misc-utils/lsblk-properties.c +++ b/misc-utils/lsblk-properties.c @@ -22,6 +22,7 @@ void lsblk_device_free_properties(struct lsblk_devprop *p) return; free(p->fstype); + free(p->fsversion); free(p->uuid); free(p->ptuuid); free(p->pttype); @@ -87,6 +88,8 @@ static struct lsblk_devprop *get_properties_by_udev(struct lsblk_device *ld) } if ((data = udev_device_get_property_value(dev, "ID_FS_TYPE"))) prop->fstype = xstrdup(data); + if ((data = udev_device_get_property_value(dev, "ID_FS_VERSION"))) + prop->fsversion = xstrdup(data); if ((data = udev_device_get_property_value(dev, "ID_PART_ENTRY_TYPE"))) prop->parttype = xstrdup(data); if ((data = udev_device_get_property_value(dev, "ID_PART_ENTRY_UUID"))) @@ -196,6 +199,7 @@ static struct lsblk_devprop *get_properties_by_file(struct lsblk_device *ld) else if (lookup(buf, "ID_PART_TABLE_UUID", &prop->ptuuid)) ; else if (lookup(buf, "ID_PART_TABLE_TYPE", &prop->pttype)) ; else if (lookup(buf, "ID_FS_TYPE", &prop->fstype)) ; + else if (lookup(buf, "ID_FS_VERSION", &prop->fsversion)) ; else if (lookup(buf, "ID_PART_ENTRY_TYPE", &prop->parttype)) ; else if (lookup(buf, "ID_PART_ENTRY_UUID", &prop->partuuid)) ; else if (lookup(buf, "ID_PART_ENTRY_FLAGS", &prop->partflags)) ; @@ -265,6 +269,8 @@ static struct lsblk_devprop *get_properties_by_blkid(struct lsblk_device *dev) prop->pttype = xstrdup(data); if (!blkid_probe_lookup_value(pr, "LABEL", &data, NULL)) prop->label = xstrdup(data); + if (!blkid_probe_lookup_value(pr, "VERSION", &data, NULL)) + prop->fsversion = xstrdup(data); if (!blkid_probe_lookup_value(pr, "PART_ENTRY_TYPE", &data, NULL)) prop->parttype = xstrdup(data); if (!blkid_probe_lookup_value(pr, "PART_ENTRY_UUID", &data, NULL)) diff --git a/misc-utils/lsblk.c b/misc-utils/lsblk.c index 1693b9af73..1ae0e28183 100644 --- a/misc-utils/lsblk.c +++ b/misc-utils/lsblk.c @@ -72,6 +72,7 @@ enum { COL_FSTYPE, COL_FSUSED, COL_FSUSEPERC, + COL_FSVERSION, COL_TARGET, COL_LABEL, COL_UUID, @@ -158,6 +159,7 @@ static struct colinfo infos[] = { [COL_FSTYPE] = { "FSTYPE", 0.1, SCOLS_FL_TRUNC, N_("filesystem type") }, [COL_FSUSED] = { "FSUSED", 5, SCOLS_FL_RIGHT, N_("filesystem size used") }, [COL_FSUSEPERC] = { "FSUSE%", 3, SCOLS_FL_RIGHT, N_("filesystem use percentage") }, + [COL_FSVERSION] = { "FSVER", 0.1, SCOLS_FL_TRUNC, N_("filesystem version") }, [COL_TARGET] = { "MOUNTPOINT", 0.10, SCOLS_FL_TRUNC, N_("where the device is mounted") }, [COL_LABEL] = { "LABEL", 0.1, 0, N_("filesystem LABEL") }, @@ -785,6 +787,11 @@ static char *device_get_data( case COL_FSUSEPERC: str = get_vfs_attribute(dev, id); break; + case COL_FSVERSION: + prop = lsblk_device_get_properties(dev); + if (prop && prop->fsversion) + str = xstrdup(prop->fsversion); + break; case COL_TARGET: { char *s = lsblk_device_get_mountpoint(dev); diff --git a/misc-utils/lsblk.h b/misc-utils/lsblk.h index 2f500c0c56..f922dc8bf9 100644 --- a/misc-utils/lsblk.h +++ b/misc-utils/lsblk.h @@ -61,6 +61,7 @@ extern struct lsblk *lsblk; /* global handler */ struct lsblk_devprop { /* udev / blkid based */ char *fstype; /* detected fs, NULL or "?" if cannot detect */ + char *fsversion; /* filesystem version */ char *uuid; /* filesystem UUID (or stack uuid) */ char *ptuuid; /* partition table UUID */ char *pttype; /* partition table type */