public inbox for util-linux@vger.kernel.org
 help / color / mirror / Atom feed
From: Michael Marineau <michael.marineau@coreos.com>
To: util-linux@vger.kernel.org
Cc: Michael Marineau <michael.marineau@coreos.com>
Subject: [PATCH 2/2] lsblk: add PARTTYPE tag
Date: Tue, 14 Jan 2014 13:19:50 -0800	[thread overview]
Message-ID: <1389734390-32485-2-git-send-email-michael.marineau@coreos.com> (raw)
In-Reply-To: <1389734390-32485-1-git-send-email-michael.marineau@coreos.com>

To stay in sync with blkid add PARTTYPE as an available output column.
---
 misc-utils/lsblk.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/misc-utils/lsblk.c b/misc-utils/lsblk.c
index 9b53be3..7061531 100644
--- a/misc-utils/lsblk.c
+++ b/misc-utils/lsblk.c
@@ -71,6 +71,7 @@ enum {
 	COL_TARGET,
 	COL_LABEL,
 	COL_UUID,
+	COL_PARTTYPE,
 	COL_PARTLABEL,
 	COL_PARTUUID,
 	COL_RA,
@@ -125,6 +126,7 @@ static struct colinfo infos[] = {
 	[COL_LABEL]  = { "LABEL",   0.1, 0, N_("filesystem LABEL") },
 	[COL_UUID]   = { "UUID",    36,  0, N_("filesystem UUID") },
 
+	[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") },
 
@@ -208,6 +210,7 @@ struct blkdev_cxt {
 	char *fstype;		/* detected fs, NULL or "?" if cannot detect */
 	char *uuid;		/* filesystem UUID (or stack uuid) */
 	char *label;		/* filesystem label */
+	char *parttype;		/* partiton type UUID */
 	char *partuuid;		/* partition UUID */
 	char *partlabel;	/* partiton label */
 	char *wwn;		/* storage WWN */
@@ -291,6 +294,7 @@ static void reset_blkdev_cxt(struct blkdev_cxt *cxt)
 	free(cxt->fstype);
 	free(cxt->uuid);
 	free(cxt->label);
+	free(cxt->parttype);
 	free(cxt->partuuid);
 	free(cxt->partlabel);
 	free(cxt->wwn);
@@ -441,6 +445,8 @@ static int get_udev_properties(struct blkdev_cxt *cxt)
 		}
 		if ((data = udev_device_get_property_value(dev, "ID_FS_TYPE")))
 			cxt->fstype = xstrdup(data);
+		if ((data = udev_device_get_property_value(dev, "ID_PART_ENTRY_TYPE")))
+			cxt->parttype = xstrdup(data);
 		if ((data = udev_device_get_property_value(dev, "ID_PART_ENTRY_UUID")))
 			cxt->partuuid = xstrdup(data);
 		if ((data = udev_device_get_property_value(dev, "ID_WWN")))
@@ -496,6 +502,8 @@ static void probe_device(struct blkdev_cxt *cxt)
 			cxt->uuid = 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))
+			cxt->parttype = xstrdup(data);
 		if (!blkid_probe_lookup_value(pr, "PART_ENTRY_UUID", &data, NULL))
 			cxt->partuuid = xstrdup(data);
 		if (!blkid_probe_lookup_value(pr, "PART_ENTRY_NAME", &data, NULL))
@@ -752,6 +760,11 @@ static void set_tt_data(struct blkdev_cxt *cxt, int col, int id, struct tt_line
 		if (cxt->uuid)
 			tt_line_set_data(ln, col, xstrdup(cxt->uuid));
 		break;
+	case COL_PARTTYPE:
+		probe_device(cxt);
+		if (cxt->parttype)
+			tt_line_set_data(ln, col, xstrdup(cxt->parttype));
+		break;
 	case COL_PARTLABEL:
 		probe_device(cxt);
 		if (!cxt->partlabel)
-- 
1.8.3.2


  reply	other threads:[~2014-01-14 21:20 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-14 21:19 [PATCH 1/2] libblkid: add PARTTYPE tag Michael Marineau
2014-01-14 21:19 ` Michael Marineau [this message]
2014-02-10  9:49   ` [PATCH 2/2] lsblk: " Karel Zak
2014-02-10  9:57 ` [PATCH 1/2] libblkid: " Karel Zak
2014-02-10 21:54   ` Michael Marineau

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1389734390-32485-2-git-send-email-michael.marineau@coreos.com \
    --to=michael.marineau@coreos.com \
    --cc=util-linux@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox