| 1 |
/* |
| 2 |
* Copyright (C) 2008 Karel Zak <[email protected]> |
| 3 |
* |
| 4 |
* Inspired by libvolume_id by |
| 5 |
* Kay Sievers <[email protected]> |
| 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 |
#define LSI_SIGNATURE "$XIDE$" |
| 25 |
|
| 26 |
static int probe_lsiraid(blkid_probe pr, |
| 27 |
const struct blkid_idmag *mag __attribute__((__unused__))) |
| 28 |
{ |
| 29 |
uint64_t off; |
| 30 |
struct lsi_metadata *lsi; |
| 31 |
|
| 32 |
if (!S_ISREG(pr->mode) && !blkid_probe_is_wholedisk(pr)) |
| 33 |
return 1; |
| 34 |
|
| 35 |
off = ((pr->size / 0x200) - 1) * 0x200; |
| 36 |
lsi = (struct lsi_metadata *) |
| 37 |
blkid_probe_get_buffer(pr, |
| 38 |
off, |
| 39 |
sizeof(struct lsi_metadata)); |
| 40 |
if (!lsi) |
| 41 |
return errno ? -errno : 1; |
| 42 |
|
| 43 |
if (memcmp(lsi->sig, LSI_SIGNATURE, sizeof(LSI_SIGNATURE)-1) != 0) |
| 44 |
return 1; |
| 45 |
if (blkid_probe_set_magic(pr, off, sizeof(lsi->sig), |
| 46 |
(unsigned char *) lsi->sig)) |
| 47 |
return 1; |
| 48 |
return 0; |
| 49 |
} |
| 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 |
|