2 * Copyright (C) 2008 Karel Zak <kzak@redhat.com>
4 * Inspired by libvolume_id by
5 * Kay Sievers <kay.sievers@vrfy.org>
7 * This file may be redistributed under the terms of the
8 * GNU Lesser General Public License.
18 struct hpfs_boot_block
22 uint8_t bytes_per_sector[2];
23 uint8_t sectors_per_cluster;
24 uint8_t n_reserved_sectors[2];
26 uint8_t n_rootdir_entries[2];
27 uint8_t n_sectors_s[2];
29 uint16_t sectors_per_fat;
30 uint16_t sectors_per_track;
31 uint16_t heads_per_cyl;
32 uint32_t n_hidden_sectors;
38 uint8_t vol_label[11];
42 } __attribute__((packed));
44 struct hpfs_super_block
49 } __attribute__((packed));
51 struct hpfs_spare_super
55 } __attribute__((packed));
58 #define HPFS_SB_OFFSET 0x2000
59 #define HPFS_SBSPARE_OFFSET 0x2200
61 static int probe_hpfs(blkid_probe pr, const struct blkid_idmag *mag)
63 struct hpfs_super_block *hs;
64 struct hpfs_spare_super *hss;
65 struct hpfs_boot_block *hbb;
69 hs = blkid_probe_get_sb(pr, mag, struct hpfs_super_block);
72 version = hs->version;
74 /* spare super block */
75 hss = (struct hpfs_spare_super *)
76 blkid_probe_get_buffer(pr,
78 sizeof(struct hpfs_spare_super));
81 if (memcmp(hss->magic, "\x49\x18\x91\xf9", 4) != 0)
84 /* boot block (with UUID and LABEL) */
85 hbb = (struct hpfs_boot_block *)
86 blkid_probe_get_buffer(pr,
88 sizeof(struct hpfs_boot_block));
91 if (memcmp(hbb->magic, "\x55\xaa", 2) == 0 &&
92 memcmp(hbb->sig_hpfs, "HPFS", 4) == 0 &&
93 hbb->sig_28h == 0x28) {
94 blkid_probe_set_label(pr, hbb->vol_label, sizeof(hbb->vol_label));
95 blkid_probe_sprintf_uuid(pr,
96 hbb->vol_serno, sizeof(hbb->vol_serno),
98 hbb->vol_serno[3], hbb->vol_serno[2],
99 hbb->vol_serno[1], hbb->vol_serno[0]);
101 blkid_probe_sprintf_version(pr, "%u", version);
106 const struct blkid_idinfo hpfs_idinfo =
109 .usage = BLKID_USAGE_FILESYSTEM,
110 .probefunc = probe_hpfs,
114 .magic = "\x49\xe8\x95\xf9",
116 .kboff = (HPFS_SB_OFFSET >> 10)