]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lsblk: add FSVER (filesystem version) column
authorKarel Zak <kzak@redhat.com>
Tue, 12 Nov 2019 12:55:55 +0000 (13:55 +0100)
committerKarel Zak <kzak@redhat.com>
Tue, 12 Nov 2019 12:55:55 +0000 (13:55 +0100)
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1764523
Signed-off-by: Karel Zak <kzak@redhat.com>
misc-utils/lsblk-properties.c
misc-utils/lsblk.c
misc-utils/lsblk.h

index a4fdeb5bd9c4b52a0fef502bb832f2f04f52723e..a1aa69531243bbe15cc814dba6d38588b2a3b550 100644 (file)
@@ -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))
index 1693b9af73ffbdca7e6b835680e11d1d3d8bb562..1ae0e28183181b18783b7f6241d3fbcc56410eb3 100644 (file)
@@ -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);
index 2f500c0c565ca7465eaf265f2d180432cfd16c80..f922dc8bf940397c131e2741c54e13bce247f115 100644 (file)
@@ -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 */