* [PATCH 1/2] libblkid: add PARTTYPE tag @ 2014-01-14 21:19 Michael Marineau 2014-01-14 21:19 ` [PATCH 2/2] lsblk: " Michael Marineau 2014-02-10 9:57 ` [PATCH 1/2] libblkid: " Karel Zak 0 siblings, 2 replies; 5+ messages in thread From: Michael Marineau @ 2014-01-14 21:19 UTC (permalink / raw) To: util-linux; +Cc: Michael Marineau Add PARTTYPE to make searching for devices partition possible without dropping to the low-level probe API and searching all devices by PART_ENTRY_TYPE. For example to find any 'EFI System Partition' devices: $ blkid -t PARTTYPE=c12a7328-f81f-11d2-ba4b-00a0c93ec93b --- libblkid/src/verify.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libblkid/src/verify.c b/libblkid/src/verify.c index 1c0ca0f..eac613e 100644 --- a/libblkid/src/verify.c +++ b/libblkid/src/verify.c @@ -38,6 +38,8 @@ static void blkid_probe_to_tags(blkid_probe pr, blkid_dev dev) blkid_set_tag(dev, "PARTUUID", data, len); else if (strcmp(name, "PART_ENTRY_NAME") == 0) blkid_set_tag(dev, "PARTLABEL", data, len); + else if (strcmp(name, "PART_ENTRY_TYPE") == 0) + blkid_set_tag(dev, "PARTTYPE", data, len); } else if (!strstr(name, "_ID")) { /* superblock UUID, LABEL, ... -- 1.8.3.2 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/2] lsblk: add PARTTYPE tag 2014-01-14 21:19 [PATCH 1/2] libblkid: add PARTTYPE tag Michael Marineau @ 2014-01-14 21:19 ` Michael Marineau 2014-02-10 9:49 ` Karel Zak 2014-02-10 9:57 ` [PATCH 1/2] libblkid: " Karel Zak 1 sibling, 1 reply; 5+ messages in thread From: Michael Marineau @ 2014-01-14 21:19 UTC (permalink / raw) To: util-linux; +Cc: Michael Marineau 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 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] lsblk: add PARTTYPE tag 2014-01-14 21:19 ` [PATCH 2/2] lsblk: " Michael Marineau @ 2014-02-10 9:49 ` Karel Zak 0 siblings, 0 replies; 5+ messages in thread From: Karel Zak @ 2014-02-10 9:49 UTC (permalink / raw) To: Michael Marineau; +Cc: util-linux On Tue, Jan 14, 2014 at 01:19:50PM -0800, Michael Marineau wrote: > misc-utils/lsblk.c | 13 +++++++++++++ > 1 file changed, 13 insertions(+) Applied, thanks. -- Karel Zak <kzak@redhat.com> http://karelzak.blogspot.com ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] libblkid: add PARTTYPE tag 2014-01-14 21:19 [PATCH 1/2] libblkid: add PARTTYPE tag Michael Marineau 2014-01-14 21:19 ` [PATCH 2/2] lsblk: " Michael Marineau @ 2014-02-10 9:57 ` Karel Zak 2014-02-10 21:54 ` Michael Marineau 1 sibling, 1 reply; 5+ messages in thread From: Karel Zak @ 2014-02-10 9:57 UTC (permalink / raw) To: Michael Marineau; +Cc: util-linux On Tue, Jan 14, 2014 at 01:19:49PM -0800, Michael Marineau wrote: > Add PARTTYPE to make searching for devices partition possible without > dropping to the low-level probe API and searching all devices by > PART_ENTRY_TYPE. For example to find any 'EFI System Partition' devices: > > $ blkid -t PARTTYPE=c12a7328-f81f-11d2-ba4b-00a0c93ec93b > --- > libblkid/src/verify.c | 2 ++ > 1 file changed, 2 insertions(+) I think it's unnecessary (and maybe bad idea) to add a new tags to the high level part of the library. The high level tags have been introduced to support mount/fsck devices by LABEL= or UUID= tags (only this is reason why we have the new PARTUUID= tag there). I'd like to keep this layer as minimal as possible (due the problem with caching in blkid.tab file). If you need information about devices then use lsblk(8) rather than blkid(8). Karel -- Karel Zak <kzak@redhat.com> http://karelzak.blogspot.com ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] libblkid: add PARTTYPE tag 2014-02-10 9:57 ` [PATCH 1/2] libblkid: " Karel Zak @ 2014-02-10 21:54 ` Michael Marineau 0 siblings, 0 replies; 5+ messages in thread From: Michael Marineau @ 2014-02-10 21:54 UTC (permalink / raw) To: Karel Zak; +Cc: util-linux On Mon, Feb 10, 2014 at 1:57 AM, Karel Zak <kzak@redhat.com> wrote: > On Tue, Jan 14, 2014 at 01:19:49PM -0800, Michael Marineau wrote: >> Add PARTTYPE to make searching for devices partition possible without >> dropping to the low-level probe API and searching all devices by >> PART_ENTRY_TYPE. For example to find any 'EFI System Partition' devices: >> >> $ blkid -t PARTTYPE=c12a7328-f81f-11d2-ba4b-00a0c93ec93b >> --- >> libblkid/src/verify.c | 2 ++ >> 1 file changed, 2 insertions(+) > > I think it's unnecessary (and maybe bad idea) to add a new tags to > the high level part of the library. The high level tags have been > introduced to support mount/fsck devices by LABEL= or UUID= tags > (only this is reason why we have the new PARTUUID= tag there). I'd > like to keep this layer as minimal as possible (due the problem with > caching in blkid.tab file). > > If you need information about devices then use lsblk(8) rather than > blkid(8). My situation is actually scanning for a partitions of particular types using the libblkid library. The high level blkid API provides a really nice way to do this except it is completely impossible to query for new tags even if the tool has sufficient privileges to re-scan devices. The low level API on the other hand is good at getting lots of detail on a single device but tedious to use for scanning an entire system for a single device. It isn't even possible to use the high level API to query for PTTYPE="gpt" for a list of candidates to directly read since whole disks get dropped from the high level API when partitions are found on them. The patch to lsblk was just an adjunct "might as well add this there too" sort of change, it doesn't actually do what I need since I need an API. What's the problem with caching you refer to? Is there a different change to the high level API that would make it more flexible while keeping the default set of values reported/cached minimal? One thought on how this may be useful in general, with PARTTYPE the following following could be used mount the same partitions that systemd-gpt-auto-generato and systemd-efi-boot-generator would: mount PARTTYPE=c12a7328-f81f-11d2-ba4b-00a0c93ec93b /boot mount PARTTYPE=933ac7e1-2eb4-4f13-b8440e14e2aef915 /home ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2014-02-10 21:54 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2014-01-14 21:19 [PATCH 1/2] libblkid: add PARTTYPE tag Michael Marineau 2014-01-14 21:19 ` [PATCH 2/2] lsblk: " Michael Marineau 2014-02-10 9:49 ` Karel Zak 2014-02-10 9:57 ` [PATCH 1/2] libblkid: " Karel Zak 2014-02-10 21:54 ` Michael Marineau
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox