--- Disclaimer: I tested a mostly similar patch against version 2.16.1 from Debian, and haven't verified it builds and runs correctly on master. VMFS is the filesystem used on VMware ESX servers. It actually includes both an LVM-like layer and a filesystem, which is why there are two different probes. A VMFS physical volume starts at a beginning of a partition, and a logical volume, which can span accross several physical volumes, include the filesystem layer. With a test vmfs dump, here is what I get from my test: $ /sbin/blkid -p test test: UUID="44f8ed49-19de-2dda-7b74-0021280083cf" VERSION="3" TYPE="VMFS_volume_member" USAGE="raid" $ /sbin/blkid -p -O 17825792 test test: UUID="44f8ed49-f328-fceb-cb65-0021280083cf" LABEL="toto" VERSION="31" TYPE="VMFS" USAGE="filesystem" We are currently developping a set of free (as in speech) tools to access VMFS volumes (named vmfs-tools), and would very much appreciate if blkid would include support for VMFS, which would make life easier for us for auto detecting VMFS volumes. Now, I am wondering about a few details. VMware ESX, as well as our tools, don't interpret the uuids the same way as blkid and libuuid does, compared to how it is stored on disk. This is what the 2 uuids above look like for ESX: 49edf844-da2dde19-747b-0021280083cf 49edf844-ebfc28f3-65cb-0021280083cf I was wondering if it wouldn't be better to mangle them such that they would at least appear with the same order, even if including extra dashes. And if so what would be the preferred way to do that. Additionally, on each physical volume, there is a reference to a logical volume uuid, stored at a couple sectors after the physical volume magic number, which I would like to expose through some variable. Do you think LOGICAL_UUID would be good ? Would blkid_probe_get_buffer be suited to get this information from the device ? Final question: what kind of information would you expect the commit message to contain ? Cheers, Mike PS: Please Cc me, I'm not subscribed. shlibs/blkid/src/superblocks/Makefile.am | 3 +- shlibs/blkid/src/superblocks/superblocks.c | 4 +- shlibs/blkid/src/superblocks/superblocks.h | 2 + shlibs/blkid/src/superblocks/vmfs.c | 75 ++++++++++++++++++++++++++++ 4 files changed, 82 insertions(+), 2 deletions(-) create mode 100644 shlibs/blkid/src/superblocks/vmfs.c diff --git a/shlibs/blkid/src/superblocks/Makefile.am b/shlibs/blkid/src/superblocks/Makefile.am index a7c4a23..3db0254 100644 --- a/shlibs/blkid/src/superblocks/Makefile.am +++ b/shlibs/blkid/src/superblocks/Makefile.am @@ -43,4 +43,5 @@ libblkid_superblocks_la_SOURCES = \ lvm.c \ zfs.c \ ubifs.c \ - bfs.c + bfs.c \ + vmfs.c diff --git a/shlibs/blkid/src/superblocks/superblocks.c b/shlibs/blkid/src/superblocks/superblocks.c index d2c7825..201e7a2 100644 --- a/shlibs/blkid/src/superblocks/superblocks.c +++ b/shlibs/blkid/src/superblocks/superblocks.c @@ -95,6 +95,7 @@ static const struct blkid_idinfo *idinfos[] = &lvm1_idinfo, &snapcow_idinfo, &luks_idinfo, + &vmfs_volume_idinfo, /* Filesystems */ &vfat_idinfo, @@ -132,7 +133,8 @@ static const struct blkid_idinfo *idinfos[] = &netware_idinfo, &btrfs_idinfo, &ubifs_idinfo, - &bfs_idinfo + &bfs_idinfo, + &vmfs_fs_idinfo }; /* diff --git a/shlibs/blkid/src/superblocks/superblocks.h b/shlibs/blkid/src/superblocks/superblocks.h index 641397a..d1f5559 100644 --- a/shlibs/blkid/src/superblocks/superblocks.h +++ b/shlibs/blkid/src/superblocks/superblocks.h @@ -61,6 +61,8 @@ extern const struct blkid_idinfo btrfs_idinfo; extern const struct blkid_idinfo ubifs_idinfo; extern const struct blkid_idinfo zfs_idinfo; extern const struct blkid_idinfo bfs_idinfo; +extern const struct blkid_idinfo vmfs_volume_idinfo; +extern const struct blkid_idinfo vmfs_fs_idinfo; /* * superblock functions diff --git a/shlibs/blkid/src/superblocks/vmfs.c b/shlibs/blkid/src/superblocks/vmfs.c new file mode 100644 index 0000000..0c46ca7 --- /dev/null +++ b/shlibs/blkid/src/superblocks/vmfs.c @@ -0,0 +1,75 @@ +/* + * Copyright (C) 2009 Mike Hommey <mh@xxxxxxxxxxxx> + * + * This file may be redistributed under the terms of the + * GNU Lesser General Public License. + */ +#include "superblocks.h" + +struct vmfs_fs_info { + uint32_t magic; + uint32_t volume_version; + uint8_t version; + uint8_t uuid[16]; + uint32_t mode; + char label[128]; +} __attribute__ ((__packed__)); + +struct vmfs_volume_info { + uint32_t magic; + uint32_t ver; + uint8_t _unknown0[122]; + uint8_t uuid[16]; +} __attribute__ ((__packed__)); + +static int probe_vmfs_fs(blkid_probe pr, const struct blkid_idmag *mag) +{ + struct vmfs_fs_info *header; + + header = blkid_probe_get_sb(pr, mag, struct vmfs_fs_info); + if (header == NULL) + return -1; + + blkid_probe_set_uuid(pr, (unsigned char *) header->uuid); + blkid_probe_set_label(pr, (unsigned char *) header->label, + sizeof(header->label)); + blkid_probe_sprintf_version(pr, "%u", header->version); + return 0; +} + +static int probe_vmfs_volume(blkid_probe pr, const struct blkid_idmag *mag) +{ + struct vmfs_volume_info *header; + + header = blkid_probe_get_sb(pr, mag, struct vmfs_volume_info); + if (header == NULL) + return -1; + + blkid_probe_set_uuid(pr, (unsigned char *) header->uuid); + blkid_probe_sprintf_version(pr, "%u", le32_to_cpu(header->ver)); + return 0; +} + +const struct blkid_idinfo vmfs_fs_idinfo = +{ + .name = "VMFS", + .usage = BLKID_USAGE_FILESYSTEM, + .probefunc = probe_vmfs_fs, + .magics = + { + { .magic = "\x5e\xf1\xab\x2f", .len = 4, .kboff = 2048 }, + { NULL } + } +}; + +const struct blkid_idinfo vmfs_volume_idinfo = +{ + .name = "VMFS_volume_member", + .usage = BLKID_USAGE_RAID, + .probefunc = probe_vmfs_volume, + .magics = + { + { .magic = "\x0d\xd0\x01\xc0", .len = 4, .kboff = 1024 }, + { NULL } + } +}; -- 1.6.4.3 -- To unsubscribe from this list: send the line "unsubscribe util-linux-ng" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html