From 211c1c4bf211531809d6812de0386ffa806948be Mon Sep 17 00:00:00 2001 From: Al Smith Date: Mon, 29 Mar 1999 11:31:02 +0000 Subject: 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. --- drivers/block/genhd.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'drivers') 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"); -- cgit v1.2.3