]> git.ipfire.org Git - thirdparty/util-linux.git/blame - libblkid/src/superblocks/highpoint_raid.c
misc: Fix various typos
[thirdparty/util-linux.git] / libblkid / src / superblocks / highpoint_raid.c
CommitLineData
5784db20
KZ
1/*
2 * Copyright (C) 2008 Karel Zak <kzak@redhat.com>
5784db20 3 *
9c863b75
KZ
4 * Inspired by libvolume_id by
5 * Kay Sievers <kay.sievers@vrfy.org>
5784db20 6 *
9c863b75
KZ
7 * This file may be redistributed under the terms of the
8 * GNU Lesser General Public License.
5784db20 9 */
5784db20
KZ
10#include <stdio.h>
11#include <stdlib.h>
12#include <unistd.h>
13#include <string.h>
14#include <stdint.h>
15
1e3cf6a2 16#include "superblocks.h"
5784db20 17
9c863b75 18struct hpt45x_metadata {
5784db20
KZ
19 uint32_t magic;
20};
21
5784db20
KZ
22#define HPT45X_MAGIC_OK 0x5a7816f3
23#define HPT45X_MAGIC_BAD 0x5a7816fd
24
538a2fe9
KZ
25static int probe_highpoint45x(blkid_probe pr,
26 const struct blkid_idmag *mag __attribute__((__unused__)))
5784db20 27{
9c863b75
KZ
28 struct hpt45x_metadata *hpt;
29 uint64_t off;
5784db20
KZ
30 uint32_t magic;
31
32 if (pr->size < 0x10000)
37f40602 33 return 1;
508e438b 34 if (!S_ISREG(pr->mode) && !blkid_probe_is_wholedisk(pr))
37f40602 35 return 1;
5784db20 36
9c863b75
KZ
37 off = ((pr->size / 0x200) - 11) * 0x200;
38 hpt = (struct hpt45x_metadata *)
39 blkid_probe_get_buffer(pr,
40 off,
41 sizeof(struct hpt45x_metadata));
42 if (!hpt)
37f40602 43 return errno ? -errno : 1;
5784db20
KZ
44 magic = le32_to_cpu(hpt->magic);
45 if (magic != HPT45X_MAGIC_OK && magic != HPT45X_MAGIC_BAD)
37f40602 46 return 1;
abc67e06
KZ
47 if (blkid_probe_set_magic(pr, off, sizeof(hpt->magic),
48 (unsigned char *) &hpt->magic))
37f40602 49 return 1;
5784db20
KZ
50 return 0;
51}
52
538a2fe9
KZ
53static int probe_highpoint37x(blkid_probe pr,
54 const struct blkid_idmag *mag __attribute__((__unused__)))
508e438b
KZ
55{
56 if (!S_ISREG(pr->mode) && !blkid_probe_is_wholedisk(pr))
37f40602 57 return 1;
508e438b
KZ
58 return 0;
59}
60
61
5784db20 62const struct blkid_idinfo highpoint45x_idinfo = {
9c100401 63 .name = "hpt45x_raid_member",
5784db20
KZ
64 .usage = BLKID_USAGE_RAID,
65 .probefunc = probe_highpoint45x,
66 .magics = BLKID_NONE_MAGIC
67};
68
69const struct blkid_idinfo highpoint37x_idinfo = {
9c100401 70 .name = "hpt37x_raid_member",
5784db20 71 .usage = BLKID_USAGE_RAID,
508e438b 72 .probefunc = probe_highpoint37x,
5784db20 73 .magics = {
2f0eb081 74 /*
9e930041 75 * Superblock offset: 4608 bytes (9 sectors)
2f0eb081
KZ
76 * Magic string offset within superblock: 32 bytes
77 *
78 * kboff = (4608 + 32) / 1024
79 * sboff = (4608 + 32) % kboff
80 */
81 { .magic = "\xf0\x16\x78\x5a", .len = 4, .kboff = 4, .sboff = 544 },
82 { .magic = "\xfd\x16\x78\x5a", .len = 4, .kboff = 4, .sboff = 544 },
5784db20
KZ
83 { NULL }
84 }
85};
86
87