mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-29 03:01:39 -04:00
[PATCH] s390: dasd partition detection
DASD allows to open a device as soon as gendisk is registered, which means the device is a fake device (capacity=0) and we do know nothing about blocksize and partitions at that point of time. In case the device is opened by someone, the bdev and inode creation is done with the fake device info and the following partition detection code is just using the wrong data. To avoid this modify the DASD state machine to make sure that the open is rejected until the device analysis is either finished or an unformatted device was detected. Signed-off-by: Horst Hummel <[email protected]> Signed-off-by: Heiko Carstens <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
This commit is contained in:
parent
fbcae7eafc
commit
90f0094dc6
5 changed files with 46 additions and 20 deletions
|
|
@ -52,6 +52,7 @@ int
|
|||
ibm_partition(struct parsed_partitions *state, struct block_device *bdev)
|
||||
{
|
||||
int blocksize, offset, size;
|
||||
loff_t i_size;
|
||||
dasd_information_t *info;
|
||||
struct hd_geometry *geo;
|
||||
char type[5] = {0,};
|
||||
|
|
@ -63,6 +64,13 @@ ibm_partition(struct parsed_partitions *state, struct block_device *bdev)
|
|||
unsigned char *data;
|
||||
Sector sect;
|
||||
|
||||
blocksize = bdev_hardsect_size(bdev);
|
||||
if (blocksize <= 0)
|
||||
return 0;
|
||||
i_size = i_size_read(bdev->bd_inode);
|
||||
if (i_size == 0)
|
||||
return 0;
|
||||
|
||||
if ((info = kmalloc(sizeof(dasd_information_t), GFP_KERNEL)) == NULL)
|
||||
goto out_noinfo;
|
||||
if ((geo = kmalloc(sizeof(struct hd_geometry), GFP_KERNEL)) == NULL)
|
||||
|
|
@ -73,9 +81,6 @@ ibm_partition(struct parsed_partitions *state, struct block_device *bdev)
|
|||
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;
|
||||
|
||||
/*
|
||||
* Get volume label, extract name and type.
|
||||
|
|
@ -111,7 +116,7 @@ ibm_partition(struct parsed_partitions *state, struct block_device *bdev)
|
|||
} 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));
|
||||
|
|
@ -168,7 +173,7 @@ 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));
|
||||
}
|
||||
|
|
@ -180,7 +185,6 @@ ibm_partition(struct parsed_partitions *state, struct block_device *bdev)
|
|||
return 1;
|
||||
|
||||
out_readerr:
|
||||
out_badsect:
|
||||
out_noioctl:
|
||||
kfree(label);
|
||||
out_nolab:
|
||||
|
|
|
|||
Loading…
Reference in a new issue