bigbiff bigbiff | e60683a | 2013-02-22 20:55:50 -0500 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2009 Mike Hommey <mh@glandium.org> |
| 3 | * |
| 4 | * This file may be redistributed under the terms of the |
| 5 | * GNU Lesser General Public License. |
| 6 | */ |
| 7 | #include "superblocks.h" |
| 8 | |
| 9 | struct vmfs_fs_info { |
| 10 | uint32_t magic; |
| 11 | uint32_t volume_version; |
| 12 | uint8_t version; |
| 13 | uint8_t uuid[16]; |
| 14 | uint32_t mode; |
| 15 | char label[128]; |
| 16 | } __attribute__ ((__packed__)); |
| 17 | |
| 18 | struct vmfs_volume_info { |
| 19 | uint32_t magic; |
| 20 | uint32_t ver; |
| 21 | uint8_t irrelevant[122]; |
| 22 | uint8_t uuid[16]; |
| 23 | } __attribute__ ((__packed__)); |
| 24 | |
| 25 | static int probe_vmfs_fs(blkid_probe pr, const struct blkid_idmag *mag) |
| 26 | { |
| 27 | struct vmfs_fs_info *header; |
| 28 | |
| 29 | header = blkid_probe_get_sb(pr, mag, struct vmfs_fs_info); |
| 30 | if (header == NULL) |
bigbiff | 7b4c7a6 | 2015-01-01 19:44:14 -0500 | [diff] [blame] | 31 | return errno ? -errno : 1; |
bigbiff bigbiff | e60683a | 2013-02-22 20:55:50 -0500 | [diff] [blame] | 32 | |
| 33 | blkid_probe_sprintf_uuid(pr, (unsigned char *) header->uuid, 16, |
| 34 | "%02x%02x%02x%02x-%02x%02x%02x%02x-" |
| 35 | "%02x%02x-%02x%02x%02x%02x%02x%02x", |
| 36 | header->uuid[3], header->uuid[2], header->uuid[1], |
| 37 | header->uuid[0], header->uuid[7], header->uuid[6], |
| 38 | header->uuid[5], header->uuid[4], header->uuid[9], |
| 39 | header->uuid[8], header->uuid[10], header->uuid[11], |
| 40 | header->uuid[12], header->uuid[13], header->uuid[14], |
| 41 | header->uuid[15]); |
| 42 | |
| 43 | blkid_probe_set_label(pr, (unsigned char *) header->label, |
| 44 | sizeof(header->label)); |
| 45 | blkid_probe_sprintf_version(pr, "%u", header->version); |
| 46 | return 0; |
| 47 | } |
| 48 | |
| 49 | static int probe_vmfs_volume(blkid_probe pr, const struct blkid_idmag *mag) |
| 50 | { |
| 51 | struct vmfs_volume_info *header; |
| 52 | unsigned char *lvm_uuid; |
| 53 | |
| 54 | header = blkid_probe_get_sb(pr, mag, struct vmfs_volume_info); |
| 55 | if (header == NULL) |
bigbiff | 7b4c7a6 | 2015-01-01 19:44:14 -0500 | [diff] [blame] | 56 | return errno ? -errno : 1; |
bigbiff bigbiff | e60683a | 2013-02-22 20:55:50 -0500 | [diff] [blame] | 57 | |
| 58 | blkid_probe_sprintf_value(pr, "UUID_SUB", |
| 59 | "%02x%02x%02x%02x-%02x%02x%02x%02x-" |
| 60 | "%02x%02x-%02x%02x%02x%02x%02x%02x", |
| 61 | header->uuid[3], header->uuid[2], header->uuid[1], |
| 62 | header->uuid[0], header->uuid[7], header->uuid[6], |
| 63 | header->uuid[5], header->uuid[4], header->uuid[9], |
| 64 | header->uuid[8], header->uuid[10], header->uuid[11], |
| 65 | header->uuid[12], header->uuid[13], header->uuid[14], |
| 66 | header->uuid[15]); |
| 67 | blkid_probe_sprintf_version(pr, "%u", le32_to_cpu(header->ver)); |
| 68 | |
| 69 | lvm_uuid = blkid_probe_get_buffer(pr, |
| 70 | 1024 * 1024 /* Start of the volume info */ |
| 71 | + 512 /* Offset to lvm info */ |
| 72 | + 20 /* Offset in lvm info */, 35); |
| 73 | if (lvm_uuid) |
| 74 | blkid_probe_strncpy_uuid(pr, lvm_uuid, 35); |
| 75 | |
| 76 | return 0; |
| 77 | } |
| 78 | |
| 79 | const struct blkid_idinfo vmfs_fs_idinfo = |
| 80 | { |
| 81 | .name = "VMFS", |
| 82 | .usage = BLKID_USAGE_FILESYSTEM, |
| 83 | .probefunc = probe_vmfs_fs, |
| 84 | .magics = |
| 85 | { |
| 86 | { .magic = "\x5e\xf1\xab\x2f", .len = 4, .kboff = 2048 }, |
| 87 | { NULL } |
| 88 | } |
| 89 | }; |
| 90 | |
| 91 | const struct blkid_idinfo vmfs_volume_idinfo = |
| 92 | { |
| 93 | .name = "VMFS_volume_member", |
| 94 | .usage = BLKID_USAGE_RAID, |
| 95 | .probefunc = probe_vmfs_volume, |
| 96 | .magics = |
| 97 | { |
| 98 | { .magic = "\x0d\xd0\x01\xc0", .len = 4, .kboff = 1024 }, |
| 99 | { NULL } |
| 100 | } |
| 101 | }; |