diff options
author | Horst Hummel <horst.hummel@de.ibm.com> | 2006-03-08 00:55:39 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-03-08 17:14:01 -0500 |
commit | 90f0094dc607abe384a412bfb7199fb667ab0735 (patch) | |
tree | 2cd4c048a95d49a532bd237388f2b50ceb55ceb6 /fs/partitions | |
parent | fbcae7eafcf7dfb315602de935d7ca85574e5c11 (diff) |
[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 <horst.hummel@de.ibm.com>
Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'fs/partitions')
-rw-r--r-- | fs/partitions/ibm.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/fs/partitions/ibm.c b/fs/partitions/ibm.c index 78010ad60e47..1e4a93835fed 100644 --- a/fs/partitions/ibm.c +++ b/fs/partitions/ibm.c | |||
@@ -52,6 +52,7 @@ int | |||
52 | ibm_partition(struct parsed_partitions *state, struct block_device *bdev) | 52 | ibm_partition(struct parsed_partitions *state, struct block_device *bdev) |
53 | { | 53 | { |
54 | int blocksize, offset, size; | 54 | int blocksize, offset, size; |
55 | loff_t i_size; | ||
55 | dasd_information_t *info; | 56 | dasd_information_t *info; |
56 | struct hd_geometry *geo; | 57 | struct hd_geometry *geo; |
57 | char type[5] = {0,}; | 58 | char type[5] = {0,}; |
@@ -63,6 +64,13 @@ ibm_partition(struct parsed_partitions *state, struct block_device *bdev) | |||
63 | unsigned char *data; | 64 | unsigned char *data; |
64 | Sector sect; | 65 | Sector sect; |
65 | 66 | ||
67 | blocksize = bdev_hardsect_size(bdev); | ||
68 | if (blocksize <= 0) | ||
69 | return 0; | ||
70 | i_size = i_size_read(bdev->bd_inode); | ||
71 | if (i_size == 0) | ||
72 | return 0; | ||
73 | |||
66 | if ((info = kmalloc(sizeof(dasd_information_t), GFP_KERNEL)) == NULL) | 74 | if ((info = kmalloc(sizeof(dasd_information_t), GFP_KERNEL)) == NULL) |
67 | goto out_noinfo; | 75 | goto out_noinfo; |
68 | if ((geo = kmalloc(sizeof(struct hd_geometry), GFP_KERNEL)) == NULL) | 76 | if ((geo = kmalloc(sizeof(struct hd_geometry), GFP_KERNEL)) == NULL) |
@@ -73,9 +81,6 @@ ibm_partition(struct parsed_partitions *state, struct block_device *bdev) | |||
73 | if (ioctl_by_bdev(bdev, BIODASDINFO, (unsigned long)info) != 0 || | 81 | if (ioctl_by_bdev(bdev, BIODASDINFO, (unsigned long)info) != 0 || |
74 | ioctl_by_bdev(bdev, HDIO_GETGEO, (unsigned long)geo) != 0) | 82 | ioctl_by_bdev(bdev, HDIO_GETGEO, (unsigned long)geo) != 0) |
75 | goto out_noioctl; | 83 | goto out_noioctl; |
76 | |||
77 | if ((blocksize = bdev_hardsect_size(bdev)) <= 0) | ||
78 | goto out_badsect; | ||
79 | 84 | ||
80 | /* | 85 | /* |
81 | * Get volume label, extract name and type. | 86 | * Get volume label, extract name and type. |
@@ -111,7 +116,7 @@ ibm_partition(struct parsed_partitions *state, struct block_device *bdev) | |||
111 | } else { | 116 | } else { |
112 | printk("CMS1/%8s:", name); | 117 | printk("CMS1/%8s:", name); |
113 | offset = (info->label_block + 1); | 118 | offset = (info->label_block + 1); |
114 | size = bdev->bd_inode->i_size >> 9; | 119 | size = i_size >> 9; |
115 | } | 120 | } |
116 | put_partition(state, 1, offset*(blocksize >> 9), | 121 | put_partition(state, 1, offset*(blocksize >> 9), |
117 | size-offset*(blocksize >> 9)); | 122 | size-offset*(blocksize >> 9)); |
@@ -168,7 +173,7 @@ ibm_partition(struct parsed_partitions *state, struct block_device *bdev) | |||
168 | else | 173 | else |
169 | printk("(nonl)/%8s:", name); | 174 | printk("(nonl)/%8s:", name); |
170 | offset = (info->label_block + 1); | 175 | offset = (info->label_block + 1); |
171 | size = (bdev->bd_inode->i_size >> 9); | 176 | size = i_size >> 9; |
172 | put_partition(state, 1, offset*(blocksize >> 9), | 177 | put_partition(state, 1, offset*(blocksize >> 9), |
173 | size-offset*(blocksize >> 9)); | 178 | size-offset*(blocksize >> 9)); |
174 | } | 179 | } |
@@ -180,7 +185,6 @@ ibm_partition(struct parsed_partitions *state, struct block_device *bdev) | |||
180 | return 1; | 185 | return 1; |
181 | 186 | ||
182 | out_readerr: | 187 | out_readerr: |
183 | out_badsect: | ||
184 | out_noioctl: | 188 | out_noioctl: |
185 | kfree(label); | 189 | kfree(label); |
186 | out_nolab: | 190 | out_nolab: |