Skip to contentSkip to conversation

blkid: recognize btrfs

PATCH Applied Eric Sandeen 2 participants 2 messages Jan 8, 2009 – Jan 20, 2009

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 blkid: recognize btrfs

Add btrfs detection to libblkid, now that the disk format should be recognizable in the future.

# misc/blkid /tmp/fsfile 
/tmp/fsfile: LABEL="mylabel" UUID="102b07f0-0e79-4b42-8a4e-1dde418bbe6d" TYPE="btrfs" 

---

lib/blkid/probe.c +17 -0
Index: e2fsprogs/lib/blkid/probe.c
===================================================================
@@ -1293,6 +1293,22 @@ static int probe_lvm2(struct blkid_probe
 
 	return 0;
 }
+
+static int probe_btrfs(struct blkid_probe *probe,
+			struct blkid_magic *id,
+			unsigned char *buf)
+{
+	struct btrfs_super_block *bs;
+	const char *label = 0;
+
+	bs = (struct btrfs_super_block *)buf;
+
+	if (strlen(bs->label))
+		label = bs->label;
+	blkid_set_tag(probe->dev, "LABEL", label, sizeof(bs->label));
+	set_uuid(probe->dev, bs->fsid, 0);
+	return 0;
+}
 /*
  * Various filesystem magics that we can check for.  Note that kboff and
  * sboff are in kilobytes and bytes respectively.  All magics are in
@@ -1386,6 +1402,7 @@ static struct blkid_magic type_array[] =
   { "lvm2pv",	 0,  0x018,  8, "LVM2 001",		probe_lvm2 },
   { "lvm2pv",	 1,  0x018,  8, "LVM2 001",		probe_lvm2 },
   { "lvm2pv",	 1,  0x218,  8, "LVM2 001",		probe_lvm2 },
+  { "btrfs",	 64,  0x40,  8, "_BHRfS_M",		probe_btrfs },
   {   NULL,	 0,	 0,  0, NULL,			NULL }
 };
 
lib/blkid/probe.h +104 -0

110 lines not on this page · raw message

Applied
#1 lore raw
Quoted 2 lines · Eric Sandeen

Add btrfs detection to libblkid, now that the disk format should be recognizable in the future.

Thanks, applied.

- Ted