4 * Code extracted from drivers/block/genhd.c
5 * Copyright (C) 1991-1998 Linus Torvalds
6 * Re-organised Feb 1998 Russell King
9 #include <linux/config.h>
11 #include <linux/genhd.h>
12 #include <linux/kernel.h>
13 #include <linux/major.h>
14 #include <linux/string.h>
15 #include <linux/blk.h>
16 #include <linux/ctype.h>
18 #include <asm/system.h>
24 * Code to understand MacOS partition tables.
27 int mac_partition(struct gendisk *hd, struct block_device *bdev,
28 unsigned long fsec, int first_part_minor)
32 int blk, blocks_in_map;
34 struct mac_partition *part;
35 struct mac_driver_desc *md;
37 /* Get 0th block and look at the first partition map entry. */
38 md = (struct mac_driver_desc *) read_dev_sector(bdev, 0, §);
41 if (be16_to_cpu(md->signature) != MAC_DRIVER_MAGIC) {
45 secsize = be16_to_cpu(md->block_size);
47 data = read_dev_sector(bdev, secsize/512, §);
50 part = (struct mac_partition *) (data + secsize%512);
51 if (be16_to_cpu(part->signature) != MAC_PARTITION_MAGIC) {
53 return 0; /* not a MacOS disk */
56 blocks_in_map = be32_to_cpu(part->map_count);
57 for (blk = 1; blk <= blocks_in_map; ++blk) {
58 int pos = blk * secsize;
60 data = read_dev_sector(bdev, pos/512, §);
63 part = (struct mac_partition *) (data + pos%512);
64 if (be16_to_cpu(part->signature) != MAC_PARTITION_MAGIC)
66 add_gd_partition(hd, first_part_minor,
67 fsec + be32_to_cpu(part->start_block) * (secsize/512),
68 be32_to_cpu(part->block_count) * (secsize/512));