Skip to contentSkip to conversation

- detect LVM2 PVs in libblkid

PATCH In review Eric Sandeen 2 participants 4 messages Jan 30, 2008 – Feb 19, 2008

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 - detect LVM2 PVs in libblkid

The anaconda folks are now using blkid instead of hand-rolled tests for filesystem type at install time, but they had one more request:

Bugzilla Bug 409321: RFE: information on blkdevs "formatted" as PVs
https://bugzilla.redhat.com/show_bug.cgi?id=409321

The attached patch does the right thing for me on my sample set of exactly 1 PV...

Any issues with reporting back something which is not actually a filesystem ("lvm2pv") ?

[root@host]# misc/blkid -c /dev/null /dev/sda2
/dev/sda2: UUID="guOQGdcOE3IafCm0190XkPZTy5fCEanQ" TYPE="lvm2pv" 
[root@host]# pvs -o pv_name,pv_uuid
  PV         PV UUID                               
  /dev/sda2  guOQGd-cOE3-IafC-m019-0XkP-ZTy5-fCEanQ

Bits liberally stolen from lvm2 userspace.

---

lib/blkid/probe.h +14 -0
Index: e2fsprogs-1.40.5/lib/blkid/probe.h
===================================================================
@@ -531,6 +531,20 @@ struct hfs_mdb {
         __u16        embed_blockcount;
 } __attribute__((packed));
 
+/* this is lvm's label_header & pv_header combined. */
+
+#define LVM2_ID_LEN 32
+
+struct lvm2_pv_label_header {
+	/* label_header */
+	__u8	id[8];		/* LABELONE */
+	__u64	sector_xl;	/* Sector number of this label */
+	__u32	crc_xl;		/* From next field to end of sector */
+	__u32	offset_xl;	/* Offset from start of struct to contents */
+	__u8	type[8];	/* LVM2 001 */
+	/* pv_header */
+	__u8	pv_uuid[LVM2_ID_LEN];
+} __attribute__ ((packed));
 
 /*
  * Byte swap functions
lib/blkid/probe.c +62 -0

74 lines not on this page · raw message

#1 lore raw
Quoted 10 lines · Eric Sandeen

The anaconda folks are now using blkid instead of hand-rolled tests for filesystem type at install time, but they had one more request:

Bugzilla Bug 409321: RFE: information on blkdevs "formatted" as PVs
https://bugzilla.redhat.com/show_bug.cgi?id=409321

The attached patch does the right thing for me on my sample set of exactly 1 PV...

Quoted 8 lines

Any issues with reporting back something which is not actually a filesystem ("lvm2pv") ?

[root@host]# misc/blkid -c /dev/null /dev/sda2
/dev/sda2: UUID="guOQGdcOE3IafCm0190XkPZTy5fCEanQ" TYPE="lvm2pv" 
[root@host]# pvs -o pv_name,pv_uuid
  PV         PV UUID                               
  /dev/sda2  guOQGd-cOE3-IafC-m019-0XkP-ZTy5-fCEanQ

The patch works for me, but it would seem the right thing would be print the UUID without the hyphens, i.e.:

guOQGdcOE3IafCm0190XkPZTy5fCEanQ

instead of

	guOQGd-cOE3-IafC-m019-0XkP-ZTy5-fCEanQ

After all, pvscan prints it with the hyphens, and blkid returns uuid's with the hyphens for other filesystems as well. And removing the hyphens aren't hard; "tr -d -" will do it.

It's not that hard to convert from one to the other; this will do it:

	for (i=0, b=1, p=uuid, q=label->pv_uuid; i <= 32; i++, b = b << 1) {
		if (b & 0x4444440)
			*p++ = '-';
		*p++ = *q++;
	}

This shouldn't screw up the anaconda folks, since they just need to know the filesystem type, right? That's all vol_id seems to return in any case.

- Ted

#2 lore raw
Quoted 8 lines · Theodore Tso

The patch works for me, but it would seem the right thing would be print the UUID without the hyphens, i.e.:

guOQGdcOE3IafCm0190XkPZTy5fCEanQ

instead of

	guOQGd-cOE3-IafC-m019-0XkP-ZTy5-fCEanQ

But it already does print it without the hyphens.

Or did you mean to say "print the UUID *with* the hyphens?"

-Eric

#3 lore raw
Quoted 7 lines · Eric Sandeen
Quoted 5 lines · Theodore Tso

The patch works for me, but it would seem the right thing would be print the UUID without the hyphens, i.e.:

guOQGdcOE3IafCm0190XkPZTy5fCEanQ

Quoted 7 lines
Quoted 3 lines

instead of

	guOQGd-cOE3-IafC-m019-0XkP-ZTy5-fCEanQ

But it already does print it without the hyphens.

Or did you mean to say "print the UUID *with* the hyphens?"

Sorry, I meant print it with the hyphens, like pvscan does and all of the other filesystem UUID's returned by blkid.

- Ted