2 * volume_id - reads filesystem label and uuid
4 * Copyright (C) 2005-2007 Kay Sievers <kay.sievers@vrfy.org>
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
31 #include "libvolume_id.h"
32 #include "libvolume_id-private.h"
34 #define MINIX_SUPERBLOCK_OFFSET 0x400
36 #define MINIX_SUPER_MAGIC 0x137F
37 #define MINIX_SUPER_MAGIC2 0x138F
38 #define MINIX2_SUPER_MAGIC 0x2468
39 #define MINIX2_SUPER_MAGIC2 0x2478
40 #define MINIX3_SUPER_MAGIC 0x4d5a
42 struct minix_super_block
46 uint16_t s_imap_blocks;
47 uint16_t s_zmap_blocks;
48 uint16_t s_firstdatazone;
49 uint16_t s_log_zone_size;
56 struct minix3_super_block {
59 uint16_t s_imap_blocks;
60 uint16_t s_zmap_blocks;
61 uint16_t s_firstdatazone;
62 uint16_t s_log_zone_size;
69 uint8_t s_disk_version;
72 int volume_id_probe_minix(struct volume_id *id, uint64_t off, uint64_t size)
75 struct minix_super_block *ms;
76 struct minix3_super_block *m3s;
78 info("probing at offset 0x%llx\n", (unsigned long long) off);
80 buf = volume_id_get_buffer(id, off + MINIX_SUPERBLOCK_OFFSET, 0x200);
84 ms = (struct minix_super_block *) buf;
86 if (ms->s_magic == MINIX_SUPER_MAGIC ||
87 ms->s_magic == bswap_16(MINIX_SUPER_MAGIC)) {
88 strcpy(id->type_version, "1");
91 if (ms->s_magic == MINIX_SUPER_MAGIC2 ||
92 ms->s_magic == bswap_16(MINIX_SUPER_MAGIC2)) {
93 strcpy(id->type_version, "1");
96 if (ms->s_magic == MINIX2_SUPER_MAGIC ||
97 ms->s_magic == bswap_16(MINIX2_SUPER_MAGIC)) {
98 strcpy(id->type_version, "2");
101 if (ms->s_magic == MINIX2_SUPER_MAGIC2 ||
102 ms->s_magic == bswap_16(MINIX2_SUPER_MAGIC2)) {
103 strcpy(id->type_version, "2");
107 m3s = (struct minix3_super_block *) buf;
108 if (m3s->s_magic == MINIX3_SUPER_MAGIC ||
109 m3s->s_magic == bswap_16(MINIX3_SUPER_MAGIC)) {
110 strcpy(id->type_version, "3");
116 volume_id_set_usage(id, VOLUME_ID_FILESYSTEM);