diff options
author | Milan Broz | 2018-06-19 12:33:20 +0200 |
---|---|---|
committer | Karel Zak | 2018-06-19 17:05:42 +0200 |
commit | 1b06b33dd0119fdae00fcc59f530200f6bdb0195 (patch) | |
tree | 02f6bfa08dfaac39aac84acfa6967bf1b32165ff /misc-utils/lsblk.c | |
parent | partx: exit with error code when partition read failed (diff) | |
download | kernel-qcow2-util-linux-1b06b33dd0119fdae00fcc59f530200f6bdb0195.tar.gz kernel-qcow2-util-linux-1b06b33dd0119fdae00fcc59f530200f6bdb0195.tar.xz kernel-qcow2-util-linux-1b06b33dd0119fdae00fcc59f530200f6bdb0195.zip |
lsblk: add partition table UUID and type fields.
This patch adds PTUUID and PTTYPE fields to lsblk, that are corresponding
fields to ID_PART_TABLE_UUID and ID_PART_TABLE_TYPE in udev database.
[kzak@redhat.com: - small change in PTUUID description]
Signed-off-by: Milan Broz <gmazyland@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'misc-utils/lsblk.c')
-rw-r--r-- | misc-utils/lsblk.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/misc-utils/lsblk.c b/misc-utils/lsblk.c index fadef65c4..79666717b 100644 --- a/misc-utils/lsblk.c +++ b/misc-utils/lsblk.c @@ -92,6 +92,8 @@ enum { COL_TARGET, COL_LABEL, COL_UUID, + COL_PTUUID, + COL_PTTYPE, COL_PARTTYPE, COL_PARTLABEL, COL_PARTUUID, @@ -172,6 +174,9 @@ static struct colinfo infos[] = { [COL_LABEL] = { "LABEL", 0.1, 0, N_("filesystem LABEL") }, [COL_UUID] = { "UUID", 36, 0, N_("filesystem UUID") }, + [COL_PTUUID] = { "PTUUID", 36, 0, N_("partition table identifier (usually UUID)") }, + [COL_PTTYPE] = { "PTTYPE", 0.1, 0, N_("partition table type") }, + [COL_PARTTYPE] = { "PARTTYPE", 36, 0, N_("partition type UUID") }, [COL_PARTLABEL] = { "PARTLABEL", 0.1, 0, N_("partition LABEL") }, [COL_PARTUUID] = { "PARTUUID", 36, 0, N_("partition UUID") }, @@ -285,6 +290,8 @@ struct blkdev_cxt { int probed; /* already probed */ char *fstype; /* detected fs, NULL or "?" if cannot detect */ char *uuid; /* filesystem UUID (or stack uuid) */ + char *ptuuid; /* partition table UUID */ + char *pttype; /* partition table type */ char *label; /* filesystem label */ char *parttype; /* partition type UUID */ char *partuuid; /* partition UUID */ @@ -394,6 +401,8 @@ static void reset_blkdev_cxt(struct blkdev_cxt *cxt) free(cxt->filename); free(cxt->fstype); free(cxt->uuid); + free(cxt->ptuuid); + free(cxt->pttype); free(cxt->label); free(cxt->parttype); free(cxt->partuuid); @@ -552,6 +561,10 @@ static int get_udev_properties(struct blkdev_cxt *cxt) cxt->uuid = xstrdup(data); unhexmangle_string(cxt->uuid); } + if ((data = udev_device_get_property_value(dev, "ID_PART_TABLE_UUID"))) + cxt->ptuuid = xstrdup(data); + if ((data = udev_device_get_property_value(dev, "ID_PART_TABLE_TYPE"))) + cxt->pttype = xstrdup(data); if ((data = udev_device_get_property_value(dev, "ID_PART_ENTRY_NAME"))) { cxt->partlabel = xstrdup(data); unhexmangle_string(cxt->partlabel); @@ -621,6 +634,10 @@ static void probe_device(struct blkdev_cxt *cxt) cxt->fstype = xstrdup(data); if (!blkid_probe_lookup_value(pr, "UUID", &data, NULL)) cxt->uuid = xstrdup(data); + if (!blkid_probe_lookup_value(pr, "PTUUID", &data, NULL)) + cxt->ptuuid = xstrdup(data); + if (!blkid_probe_lookup_value(pr, "PTTYPE", &data, NULL)) + cxt->pttype = xstrdup(data); if (!blkid_probe_lookup_value(pr, "LABEL", &data, NULL)) cxt->label = xstrdup(data); if (!blkid_probe_lookup_value(pr, "PART_ENTRY_TYPE", &data, NULL)) @@ -964,6 +981,16 @@ static void set_scols_data(struct blkdev_cxt *cxt, int col, int id, struct libsc if (cxt->uuid) str = xstrdup(cxt->uuid); break; + case COL_PTUUID: + probe_device(cxt); + if (cxt->ptuuid) + str = xstrdup(cxt->ptuuid); + break; + case COL_PTTYPE: + probe_device(cxt); + if (cxt->pttype) + str = xstrdup(cxt->pttype); + break; case COL_PARTTYPE: probe_device(cxt); if (cxt->parttype) |