[PATCH] Allow subpartitions inside logical DOS partitions

From: Martin Blom
Date: Mon Apr 10 2006 - 14:27:53 EST



The following patch makes the subpartition scan in fs/partitions/msdos.c
scan all partitions, not only the primary ones.

Useful for the AROS/Amithlon subpartition patch (see separate mail).

Comments?



diff -ru linux-2.6.16/fs/partitions/check.h
logical-subpartitions/fs/partitions/check.h
--- linux-2.6.16/fs/partitions/check.h 2006-04-10 14:05:43.000000000 +0200
+++ logical-subpartitions/fs/partitions/check.h 2006-04-10
14:09:11.000000000 +0200
@@ -13,6 +13,7 @@
sector_t from;
sector_t size;
int flags;
+ int id;
} parts[MAX_PART];
int next;
int limit;
diff -ru linux-2.6.16/fs/partitions/msdos.c
logical-subpartitions/fs/partitions/msdos.c
--- linux-2.6.16/fs/partitions/msdos.c 2006-04-10 14:05:43.000000000 +0200
+++ logical-subpartitions/fs/partitions/msdos.c 2006-04-10
14:09:11.000000000 +0200
@@ -132,6 +132,7 @@
}

put_partition(state, state->next, next, size);
+ state->parts[state->next].id = SYS_IND(p);
if (SYS_IND(p) == LINUX_RAID_PARTITION)
state->parts[state->next].flags = 1;
loopct = 0;
@@ -384,7 +385,7 @@
Sector sect;
unsigned char *data;
struct partition *p;
- int slot;
+ int slot, max_slot;

data = read_dev_sector(bdev, 0, &sect);
if (!data)
@@ -442,6 +443,7 @@
continue;
}
put_partition(state, slot, start, size);
+ state->parts[slot].id = SYS_IND(p);
if (SYS_IND(p) == LINUX_RAID_PARTITION)
state->parts[slot].flags = 1;
if (SYS_IND(p) == DM6_PARTITION)
@@ -453,12 +455,13 @@
printk("\n");

/* second pass - output for each on a separate line */
- p = (struct partition *) (0x1be + data);
- for (slot = 1 ; slot <= 4 ; slot++, p++) {
- unsigned char id = SYS_IND(p);
+ for (slot = 1, max_slot = state->next ; slot < max_slot ; slot++) {
+ unsigned char id = (unsigned char) state->parts[slot].id;
+ u32 start = state->parts[slot].from;
+ u32 size = state->parts[slot].size;
int n;

- if (!NR_SECTS(p))
+ if (!size)
continue;

for (n = 0; subtypes[n].parse && id != subtypes[n].id; n++)
@@ -466,8 +469,7 @@

if (!subtypes[n].parse)
continue;
- subtypes[n].parse(state, bdev, START_SECT(p)*sector_size,
- NR_SECTS(p)*sector_size, slot);
+ subtypes[n].parse(state, bdev, start, size, slot);
}
put_dev_sector(sect);
return 1;


--
---- Martin Blom --------------------------- martin@xxxxxxxx ----
Eccl 1:18 http://martin.blom.org/

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/