/src/util-linux/libblkid/src/superblocks/vmfs.c
Line  | Count  | Source (jump to first uncovered line)  | 
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  | 0  | { | 
27  | 0  |   const struct vmfs_fs_info *header;  | 
28  |  | 
  | 
29  | 0  |   header = blkid_probe_get_sb(pr, mag, struct vmfs_fs_info);  | 
30  | 0  |   if (header == NULL)  | 
31  | 0  |     return errno ? -errno : 1;  | 
32  |  |  | 
33  | 0  |   blkid_probe_sprintf_uuid(pr, (unsigned char *) header->uuid, 16,  | 
34  | 0  |     "%02x%02x%02x%02x-%02x%02x%02x%02x-"  | 
35  | 0  |     "%02x%02x-%02x%02x%02x%02x%02x%02x",  | 
36  | 0  |     header->uuid[3], header->uuid[2], header->uuid[1],  | 
37  | 0  |     header->uuid[0], header->uuid[7], header->uuid[6],  | 
38  | 0  |     header->uuid[5], header->uuid[4], header->uuid[9],  | 
39  | 0  |     header->uuid[8], header->uuid[10], header->uuid[11],  | 
40  | 0  |     header->uuid[12], header->uuid[13], header->uuid[14],  | 
41  | 0  |     header->uuid[15]);  | 
42  |  | 
  | 
43  | 0  |   blkid_probe_set_label(pr, (unsigned char *) header->label,  | 
44  | 0  |           sizeof(header->label));  | 
45  | 0  |   blkid_probe_sprintf_version(pr, "%u", header->version);  | 
46  | 0  |   return 0;  | 
47  | 0  | }  | 
48  |  |  | 
49  |  | static int probe_vmfs_volume(blkid_probe pr, const struct blkid_idmag *mag)  | 
50  | 0  | { | 
51  | 0  |   const struct vmfs_volume_info *header;  | 
52  | 0  |   const unsigned char *lvm_uuid;  | 
53  |  | 
  | 
54  | 0  |   header = blkid_probe_get_sb(pr, mag, struct vmfs_volume_info);  | 
55  | 0  |   if (header == NULL)  | 
56  | 0  |     return errno ? -errno : 1;  | 
57  |  |  | 
58  | 0  |   blkid_probe_sprintf_value(pr, "UUID_SUB",  | 
59  | 0  |     "%02x%02x%02x%02x-%02x%02x%02x%02x-"  | 
60  | 0  |     "%02x%02x-%02x%02x%02x%02x%02x%02x",  | 
61  | 0  |     header->uuid[3], header->uuid[2], header->uuid[1],  | 
62  | 0  |     header->uuid[0], header->uuid[7], header->uuid[6],  | 
63  | 0  |     header->uuid[5], header->uuid[4], header->uuid[9],  | 
64  | 0  |     header->uuid[8], header->uuid[10], header->uuid[11],  | 
65  | 0  |     header->uuid[12], header->uuid[13], header->uuid[14],  | 
66  | 0  |     header->uuid[15]);  | 
67  | 0  |   blkid_probe_sprintf_version(pr, "%u", le32_to_cpu(header->ver));  | 
68  |  | 
  | 
69  | 0  |   lvm_uuid = blkid_probe_get_buffer(pr,  | 
70  | 0  |         1024 * 1024 /* Start of the volume info */  | 
71  | 0  |         + 512 /* Offset to lvm info */  | 
72  | 0  |         + 20 /* Offset in lvm info */, 35);  | 
73  | 0  |   if (lvm_uuid)  | 
74  | 0  |     blkid_probe_strncpy_uuid(pr, lvm_uuid, 35);  | 
75  |  | 
  | 
76  | 0  |   return 0;  | 
77  | 0  | }  | 
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  |  | };  |