X-Git-Url: http://pilppa.org/gitweb/gitweb.cgi?a=blobdiff_plain;f=fs%2Fpartitions%2Fibm.c;h=9f7ad4244f63d64ed723939c568fc88de53ae7c3;hb=dda034bcb51a0a28318046d74d664e0fc5f7d1d4;hp=6327bcb2d73df0d99b90dbde3a14e7958e7de330;hpb=24bfb00123e82a2e70bd115277d922438813515b;p=linux-2.6-omap-h63xx.git diff --git a/fs/partitions/ibm.c b/fs/partitions/ibm.c index 6327bcb2d73..9f7ad4244f6 100644 --- a/fs/partitions/ibm.c +++ b/fs/partitions/ibm.c @@ -1,18 +1,11 @@ /* - * File...........: linux/fs/partitions/ibm.c + * File...........: linux/fs/partitions/ibm.c * Author(s)......: Holger Smolinski * Volker Sameske * Bugreports.to..: * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 1999,2000 - - * History of changes (starts July 2000) - * 07/10/00 Fixed detection of CMS formatted disks - * 02/13/00 VTOC partition support added - * 12/27/01 fixed PL030593 (CMS reserved minidisk not detected on 64 bit) - * 07/24/03 no longer using contents of freed page for CMS label recognition (BZ3611) */ -#include #include #include #include @@ -25,7 +18,7 @@ #include "ibm.h" /* - * compute the block number from a + * compute the block number from a * cyl-cyl-head-head structure */ static inline int @@ -34,9 +27,8 @@ cchh2blk (struct vtoc_cchh *ptr, struct hd_geometry *geo) { ptr->hh * geo->sectors; } - /* - * compute the block number from a + * compute the block number from a * cyl-cyl-head-head-block structure */ static inline int @@ -48,32 +40,40 @@ cchhb2blk (struct vtoc_cchhb *ptr, struct hd_geometry *geo) { /* */ -int +int ibm_partition(struct parsed_partitions *state, struct block_device *bdev) { - int blocksize, offset, size; + int blocksize, offset, size,res; + loff_t i_size; dasd_information_t *info; struct hd_geometry *geo; char type[5] = {0,}; char name[7] = {0,}; - struct vtoc_volume_label *vlabel; + union label_t { + struct vtoc_volume_label vol; + struct vtoc_cms_label cms; + } *label; unsigned char *data; Sector sect; + res = 0; + blocksize = bdev_hardsect_size(bdev); + if (blocksize <= 0) + goto out_exit; + i_size = i_size_read(bdev->bd_inode); + if (i_size == 0) + goto out_exit; + if ((info = kmalloc(sizeof(dasd_information_t), GFP_KERNEL)) == NULL) - goto out_noinfo; + goto out_exit; if ((geo = kmalloc(sizeof(struct hd_geometry), GFP_KERNEL)) == NULL) goto out_nogeo; - if ((vlabel = kmalloc(sizeof(struct vtoc_volume_label), - GFP_KERNEL)) == NULL) - goto out_novlab; - + if ((label = kmalloc(sizeof(union label_t), GFP_KERNEL)) == NULL) + goto out_nolab; + if (ioctl_by_bdev(bdev, BIODASDINFO, (unsigned long)info) != 0 || ioctl_by_bdev(bdev, HDIO_GETGEO, (unsigned long)geo) != 0) - goto out_noioctl; - - if ((blocksize = bdev_hardsect_size(bdev)) <= 0) - goto out_badsect; + goto out_freeall; /* * Get volume label, extract name and type. @@ -87,12 +87,14 @@ ibm_partition(struct parsed_partitions *state, struct block_device *bdev) strncpy(name, data + 8, 6); else strncpy(name, data + 4, 6); - memcpy (vlabel, data, sizeof(struct vtoc_volume_label)); + memcpy(label, data, sizeof(union label_t)); put_dev_sector(sect); EBCASC(type, 4); EBCASC(name, 6); + res = 1; + /* * Three different types: CMS1, VOL1 and LNX1/unlabeled */ @@ -100,18 +102,16 @@ ibm_partition(struct parsed_partitions *state, struct block_device *bdev) /* * VM style CMS1 labeled disk */ - int *label = (int *) vlabel; - - if (label[13] != 0) { + if (label->cms.disk_offset != 0) { printk("CMS1/%8s(MDSK):", name); /* disk is reserved minidisk */ - blocksize = label[3]; - offset = label[13]; - size = (label[7] - 1)*(blocksize >> 9); + blocksize = label->cms.block_size; + offset = label->cms.disk_offset; + size = (label->cms.block_count - 1) * (blocksize >> 9); } else { printk("CMS1/%8s:", name); offset = (info->label_block + 1); - size = bdev->bd_inode->i_size >> 9; + size = i_size >> 9; } put_partition(state, 1, offset*(blocksize >> 9), size-offset*(blocksize >> 9)); @@ -126,7 +126,7 @@ ibm_partition(struct parsed_partitions *state, struct block_device *bdev) printk("VOL1/%8s:", name); /* get block number and read then go through format1 labels */ - blk = cchhb2blk(&vlabel->vtoc, geo) + 1; + blk = cchhb2blk(&label->vol.vtoc, geo) + 1; counter = 0; while ((data = read_dev_sector(bdev, blk*(blocksize/512), §)) != NULL) { @@ -149,16 +149,19 @@ ibm_partition(struct parsed_partitions *state, struct block_device *bdev) /* OK, we got valid partition data */ offset = cchh2blk(&f1.DS1EXT1.llimit, geo); - size = cchh2blk(&f1.DS1EXT1.ulimit, geo) - + size = cchh2blk(&f1.DS1EXT1.ulimit, geo) - offset + geo->sectors; if (counter >= state->limit) break; - put_partition(state, counter + 1, - offset * (blocksize >> 9), - size * (blocksize >> 9)); + put_partition(state, counter + 1, + offset * (blocksize >> 9), + size * (blocksize >> 9)); counter++; blk++; } + if (!data) + /* Are we not supposed to report this ? */ + goto out_readerr; } else { /* * Old style LNX1 or unlabeled disk @@ -168,25 +171,23 @@ ibm_partition(struct parsed_partitions *state, struct block_device *bdev) else printk("(nonl)/%8s:", name); offset = (info->label_block + 1); - size = (bdev->bd_inode->i_size >> 9); + size = i_size >> 9; put_partition(state, 1, offset*(blocksize >> 9), - size-offset*(blocksize >> 9)); + size-offset*(blocksize >> 9)); } printk("\n"); - kfree(vlabel); - kfree(geo); - kfree(info); - return 1; - + goto out_freeall; + + out_readerr: -out_badsect: -out_noioctl: - kfree(vlabel); -out_novlab: + res = -1; +out_freeall: + kfree(label); +out_nolab: kfree(geo); out_nogeo: kfree(info); -out_noinfo: - return 0; +out_exit: + return res; }