summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorAl Smith <Al.Smith@aeschi.ch.eu.org>1999-03-29 11:31:02 +0000
committerAl Smith <Al.Smith@aeschi.ch.eu.org>1999-03-29 11:31:02 +0000
commit211c1c4bf211531809d6812de0386ffa806948be (patch)
tree43c2ebe8b45eb97dbf7eaf5af40bbce299942812 /drivers
parent11fb413571e57b2b1c054e357fcd077de58252ee (diff)
Updated sgi_partition() to cope with running on non big-endian
machines. It should now be possible to put a SGI drive into a little-endian machine and have the partition table validated correctly.
Diffstat (limited to 'drivers')
-rw-r--r--drivers/block/genhd.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/drivers/block/genhd.c b/drivers/block/genhd.c
index 889913b54..99b2bf78a 100644
--- a/drivers/block/genhd.c
+++ b/drivers/block/genhd.c
@@ -765,8 +765,8 @@ static int sun_partition(struct gendisk *hd, kdev_t dev, unsigned long first_sec
static int sgi_partition(struct gendisk *hd, kdev_t dev, unsigned long first_sector)
{
- int i, csum;
- unsigned int *ui;
+ int i, csum, magic;
+ unsigned int *ui, start, blocks, cs;
struct buffer_head *bh;
struct sgi_disklabel {
int magic_mushroom; /* Big fat spliff... */
@@ -796,15 +796,18 @@ static int sgi_partition(struct gendisk *hd, kdev_t dev, unsigned long first_sec
}
label = (struct sgi_disklabel *) bh->b_data;
p = &label->partitions[0];
- if(label->magic_mushroom != SGI_LABEL_MAGIC) {
+ magic = label->magic_mushroom;
+ if(be32_to_cpu(magic) != SGI_LABEL_MAGIC) {
printk("Dev %s SGI disklabel: bad magic %08x\n",
- kdevname(dev), label->magic_mushroom);
+ kdevname(dev), magic);
brelse(bh);
return 0;
}
ui = ((unsigned int *) (label + 1)) - 1;
- for(csum = 0; ui >= ((unsigned int *) label);)
- csum += *ui--;
+ for(csum = 0; ui >= ((unsigned int *) label);) {
+ cs = *ui--;
+ csum += be32_to_cpu(cs);
+ }
if(csum) {
printk("Dev %s SGI disklabel: csum bad, label corrupted\n",
kdevname(dev));
@@ -817,9 +820,11 @@ static int sgi_partition(struct gendisk *hd, kdev_t dev, unsigned long first_sec
* current_minor.
*/
for(i = 0; i < 16; i++, p++) {
- if(!(p->num_blocks))
+ blocks = be32_to_cpu(p->num_blocks);
+ start = be32_to_cpu(p->first_block);
+ if(!blocks)
continue;
- add_partition(hd, current_minor, p->first_block, p->num_blocks);
+ add_partition(hd, current_minor, start, blocks);
current_minor++;
}
printk("\n");