/src/util-linux/libblkid/src/superblocks/lsi_raid.c
Line  | Count  | Source (jump to first uncovered line)  | 
1  |  | /*  | 
2  |  |  * Copyright (C) 2008 Karel Zak <kzak@redhat.com>  | 
3  |  |  *  | 
4  |  |  * Inspired by libvolume_id by  | 
5  |  |  *     Kay Sievers <kay.sievers@vrfy.org>  | 
6  |  |  *  | 
7  |  |  * This file may be redistributed under the terms of the  | 
8  |  |  * GNU Lesser General Public License.  | 
9  |  |  */  | 
10  |  |  | 
11  |  | #include <stdio.h>  | 
12  |  | #include <stdlib.h>  | 
13  |  | #include <unistd.h>  | 
14  |  | #include <string.h>  | 
15  |  | #include <stdint.h>  | 
16  |  |  | 
17  |  | #include "superblocks.h"  | 
18  |  |  | 
19  |  | struct lsi_metadata { | 
20  |  |   uint8_t   sig[6];  | 
21  |  | };  | 
22  |  |  | 
23  |  |  | 
24  | 13.2k  | #define LSI_SIGNATURE   "$XIDE$"  | 
25  |  |  | 
26  |  | static int probe_lsiraid(blkid_probe pr,  | 
27  |  |     const struct blkid_idmag *mag __attribute__((__unused__)))  | 
28  | 6.60k  | { | 
29  | 6.60k  |   uint64_t off;  | 
30  | 6.60k  |   struct lsi_metadata *lsi;  | 
31  |  |  | 
32  | 6.60k  |   if (!S_ISREG(pr->mode) && !blkid_probe_is_wholedisk(pr))  | 
33  | 0  |     return 1;  | 
34  |  |  | 
35  | 6.60k  |   off = ((pr->size / 0x200) - 1) * 0x200;  | 
36  | 6.60k  |   lsi = (struct lsi_metadata *)  | 
37  | 6.60k  |     blkid_probe_get_buffer(pr,  | 
38  | 6.60k  |         off,  | 
39  | 6.60k  |         sizeof(struct lsi_metadata));  | 
40  | 6.60k  |   if (!lsi)  | 
41  | 0  |     return errno ? -errno : 1;  | 
42  |  |  | 
43  | 6.60k  |   if (memcmp(lsi->sig, LSI_SIGNATURE, sizeof(LSI_SIGNATURE)-1) != 0)  | 
44  | 6.60k  |     return 1;  | 
45  | 0  |   if (blkid_probe_set_magic(pr, off, sizeof(lsi->sig),  | 
46  | 0  |         (unsigned char *) lsi->sig))  | 
47  | 0  |     return 1;  | 
48  | 0  |   return 0;  | 
49  | 0  | }  | 
50  |  |  | 
51  |  | const struct blkid_idinfo lsiraid_idinfo = { | 
52  |  |   .name   = "lsi_mega_raid_member",  | 
53  |  |   .usage    = BLKID_USAGE_RAID,  | 
54  |  |   .minsz    = 0x10000,  | 
55  |  |   .probefunc  = probe_lsiraid,  | 
56  |  |   .magics   = BLKID_NONE_MAGIC  | 
57  |  | };  | 
58  |  |  | 
59  |  |  |