patch-2.4.11-dontuse linux/fs/partitions/mac.c
Next file: linux/fs/partitions/mac.h
Previous file: linux/fs/partitions/ldm.h
Back to the patch index
Back to the overall index
- Lines: 123
- Date:
Mon Oct 1 20:03:26 2001
- Orig file:
v2.4.10/linux/fs/partitions/mac.c
- Orig date:
Sun Sep 17 09:51:57 2000
diff -u --recursive --new-file v2.4.10/linux/fs/partitions/mac.c linux/fs/partitions/mac.c
@@ -20,7 +20,7 @@
#include "check.h"
#include "mac.h"
-#ifdef CONFIG_PPC
+#ifdef CONFIG_ALL_PPC
extern void note_bootable_part(kdev_t dev, int part, int goodness);
#endif
@@ -36,69 +36,54 @@
stg[i] = 0;
}
-int mac_partition(struct gendisk *hd, kdev_t dev, unsigned long fsec, int first_part_minor)
+int mac_partition(struct gendisk *hd, struct block_device *bdev,
+ unsigned long fsec, int first_part_minor)
{
- struct buffer_head *bh;
+ Sector sect;
+ unsigned char *data;
int blk, blocks_in_map;
- int dev_bsize, dev_pos, pos;
unsigned secsize;
-#ifdef CONFIG_PPC
+#ifdef CONFIG_ALL_PPC
int found_root = 0;
int found_root_goodness = 0;
#endif
struct mac_partition *part;
struct mac_driver_desc *md;
- dev_bsize = get_ptable_blocksize(dev);
- dev_pos = 0;
/* Get 0th block and look at the first partition map entry. */
- if ((bh = bread(dev, 0, dev_bsize)) == 0) {
- printk("%s: error reading partition table\n",
- kdevname(dev));
- return -1;
- }
- md = (struct mac_driver_desc *) bh->b_data;
+ md = (struct mac_driver_desc *) read_dev_sector(bdev, 0, §);
+ if (!md)
+ return -1;
if (be16_to_cpu(md->signature) != MAC_DRIVER_MAGIC) {
- brelse(bh);
+ put_dev_sector(sect);
return 0;
}
secsize = be16_to_cpu(md->block_size);
- if (secsize >= dev_bsize) {
- brelse(bh);
- dev_pos = secsize;
- if ((bh = bread(dev, secsize/dev_bsize, dev_bsize)) == 0) {
- printk("%s: error reading Mac partition table\n",
- kdevname(dev));
- return -1;
- }
- }
- part = (struct mac_partition *) (bh->b_data + secsize - dev_pos);
+ put_dev_sector(sect);
+ data = read_dev_sector(bdev, secsize/512, §);
+ if (!data)
+ return -1;
+ part = (struct mac_partition *) (data + secsize%512);
if (be16_to_cpu(part->signature) != MAC_PARTITION_MAGIC) {
- brelse(bh);
+ put_dev_sector(sect);
return 0; /* not a MacOS disk */
}
printk(" [mac]");
blocks_in_map = be32_to_cpu(part->map_count);
for (blk = 1; blk <= blocks_in_map; ++blk) {
- pos = blk * secsize;
- if (pos >= dev_pos + dev_bsize) {
- brelse(bh);
- dev_pos = pos;
- if ((bh = bread(dev, pos/dev_bsize, dev_bsize)) == 0) {
- printk("%s: error reading partition table\n",
- kdevname(dev));
- return -1;
- }
- }
- part = (struct mac_partition *) (bh->b_data + pos - dev_pos);
+ int pos = blk * secsize;
+ put_dev_sector(sect);
+ data = read_dev_sector(bdev, pos/512, §);
+ if (!data)
+ return -1;
+ part = (struct mac_partition *) (data + pos%512);
if (be16_to_cpu(part->signature) != MAC_PARTITION_MAGIC)
break;
- blocks_in_map = be32_to_cpu(part->map_count);
add_gd_partition(hd, first_part_minor,
fsec + be32_to_cpu(part->start_block) * (secsize/512),
be32_to_cpu(part->block_count) * (secsize/512));
-#ifdef CONFIG_PPC
+#ifdef CONFIG_ALL_PPC
/*
* If this is the first bootable partition, tell the
* setup code, in case it wants to make this the root.
@@ -139,15 +124,17 @@
found_root_goodness = goodness;
}
}
-#endif /* CONFIG_PPC */
+#endif /* CONFIG_ALL_PPC */
++first_part_minor;
}
-#ifdef CONFIG_PPC
+#ifdef CONFIG_ALL_PPC
if (found_root_goodness)
- note_bootable_part(dev, found_root, found_root_goodness);
+ note_bootable_part(to_kdev_t(bdev->bd_dev),
+ found_root, found_root_goodness);
#endif
- brelse(bh);
+
+ put_dev_sector(sect);
printk("\n");
return 1;
}
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)