2
* Minix partition parsing code
4
* Copyright (C) 2009 Karel Zak <kzak@redhat.com>
6
* This file may be redistributed under the terms of the
7
* GNU Lesser General Public License.
14
#include "partitions.h"
18
* Minix subpartitions are always within primary dos partition.
20
#define MINIX_MAXPARTITIONS 4
22
static int probe_minix_pt(blkid_probe pr, const struct blkid_idmag *mag)
24
struct dos_partition *p;
25
blkid_parttable tab = NULL;
26
blkid_partition parent;
31
data = blkid_probe_get_sector(pr, 0);
35
ls = blkid_probe_get_partlist(pr);
39
/* Parent is required, because Minix uses the same PT as DOS and
40
* difference is only in primary partition (parent) type.
42
parent = blkid_partlist_get_parent(ls);
46
if (blkid_partition_get_type(parent) != BLKID_MINIX_PARTITION)
49
if (blkid_partitions_need_typeonly(pr))
50
/* caller does not ask for details about partitions */
53
p = (struct dos_partition *) (data + BLKID_MSDOS_PT_OFFSET);
55
tab = blkid_partlist_new_parttable(ls, "minix", BLKID_MSDOS_PT_OFFSET);
59
for (i = 0; i < MINIX_MAXPARTITIONS; i++, p++) {
63
if (p->sys_type != BLKID_MINIX_PARTITION)
66
start = dos_partition_start(p);
67
size = dos_partition_size(p);
69
if (parent && !blkid_is_nested_dimension(parent, start, size)) {
70
DBG(DEBUG_LOWPROBE, printf(
71
"WARNING: minix partition (%d) overflow "
72
"detected, ignore\n", i));
76
par = blkid_partlist_add_partition(ls, tab, start, size);
80
blkid_partition_set_type(par, p->sys_type);
81
blkid_partition_set_flags(par, p->boot_ind);
93
const struct blkid_idinfo minix_pt_idinfo =
96
.probefunc = probe_minix_pt,
99
{ .magic = "\x55\xAA", .len = 2, .sboff = 510 },