2 * File...........: linux/fs/partitions/ibm.c
3 * Author(s)......: Holger Smolinski <Holger.Smolinski@de.ibm.com>
4 * Volker Sameske <sameske@de.ibm.com>
5 * Bugreports.to..: <Linux390@de.ibm.com>
6 * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 1999,2000
9 #include <linux/buffer_head.h>
10 #include <linux/hdreg.h>
11 #include <linux/slab.h>
13 #include <asm/ebcdic.h>
14 #include <asm/uaccess.h>
21 * compute the block number from a
22 * cyl-cyl-head-head structure
25 cchh2blk (struct vtoc_cchh
*ptr
, struct hd_geometry
*geo
) {
26 return ptr
->cc
* geo
->heads
* geo
->sectors
+
27 ptr
->hh
* geo
->sectors
;
31 * compute the block number from a
32 * cyl-cyl-head-head-block structure
35 cchhb2blk (struct vtoc_cchhb
*ptr
, struct hd_geometry
*geo
) {
36 return ptr
->cc
* geo
->heads
* geo
->sectors
+
37 ptr
->hh
* geo
->sectors
+
44 ibm_partition(struct parsed_partitions
*state
, struct block_device
*bdev
)
46 int blocksize
, offset
, size
,res
;
48 dasd_information2_t
*info
;
49 struct hd_geometry
*geo
;
53 struct vtoc_volume_label vol
;
54 struct vtoc_cms_label cms
;
60 blocksize
= bdev_hardsect_size(bdev
);
63 i_size
= i_size_read(bdev
->bd_inode
);
67 info
= kmalloc(sizeof(dasd_information2_t
), GFP_KERNEL
);
70 geo
= kmalloc(sizeof(struct hd_geometry
), GFP_KERNEL
);
73 label
= kmalloc(sizeof(union label_t
), GFP_KERNEL
);
77 if (ioctl_by_bdev(bdev
, BIODASDINFO2
, (unsigned long)info
) != 0 ||
78 ioctl_by_bdev(bdev
, HDIO_GETGEO
, (unsigned long)geo
) != 0)
82 * Get volume label, extract name and type.
84 data
= read_dev_sector(bdev
, info
->label_block
*(blocksize
/512), §
);
88 strncpy (type
, data
, 4);
89 if ((!info
->FBA_layout
) && (!strcmp(info
->type
, "ECKD")))
90 strncpy(name
, data
+ 8, 6);
92 strncpy(name
, data
+ 4, 6);
93 memcpy(label
, data
, sizeof(union label_t
));
102 * Three different formats: LDL, CDL and unformated disk
104 * identified by info->format
106 * unformated disks we do not have to care about
108 if (info
->format
== DASD_FORMAT_LDL
) {
109 if (strncmp(type
, "CMS1", 4) == 0) {
111 * VM style CMS1 labeled disk
113 if (label
->cms
.disk_offset
!= 0) {
114 printk("CMS1/%8s(MDSK):", name
);
115 /* disk is reserved minidisk */
116 blocksize
= label
->cms
.block_size
;
117 offset
= label
->cms
.disk_offset
;
118 size
= (label
->cms
.block_count
- 1)
121 printk("CMS1/%8s:", name
);
122 offset
= (info
->label_block
+ 1);
127 * Old style LNX1 or unlabeled disk
129 if (strncmp(type
, "LNX1", 4) == 0)
130 printk ("LNX1/%8s:", name
);
133 offset
= (info
->label_block
+ 1);
136 put_partition(state
, 1, offset
*(blocksize
>> 9),
137 size
-offset
*(blocksize
>> 9));
138 } else if (info
->format
== DASD_FORMAT_CDL
) {
140 * New style CDL formatted disk
146 * check if VOL1 label is available
147 * if not, something is wrong, skipping partition detection
149 if (strncmp(type
, "VOL1", 4) == 0) {
150 printk("VOL1/%8s:", name
);
152 * get block number and read then go through format1
155 blk
= cchhb2blk(&label
->vol
.vtoc
, geo
) + 1;
157 data
= read_dev_sector(bdev
, blk
* (blocksize
/512),
159 while (data
!= NULL
) {
160 struct vtoc_format1_label f1
;
163 sizeof(struct vtoc_format1_label
));
164 put_dev_sector(sect
);
166 /* skip FMT4 / FMT5 / FMT7 labels */
167 if (f1
.DS1FMTID
== _ascebc
['4']
168 || f1
.DS1FMTID
== _ascebc
['5']
169 || f1
.DS1FMTID
== _ascebc
['7']) {
171 data
= read_dev_sector(bdev
, blk
*
177 /* only FMT1 valid at this point */
178 if (f1
.DS1FMTID
!= _ascebc
['1'])
181 /* OK, we got valid partition data */
182 offset
= cchh2blk(&f1
.DS1EXT1
.llimit
, geo
);
183 size
= cchh2blk(&f1
.DS1EXT1
.ulimit
, geo
) -
184 offset
+ geo
->sectors
;
185 if (counter
>= state
->limit
)
187 put_partition(state
, counter
+ 1,
188 offset
* (blocksize
>> 9),
189 size
* (blocksize
>> 9));
192 data
= read_dev_sector(bdev
,
193 blk
* (blocksize
/512),
198 /* Are we not supposed to report this ? */
201 printk(KERN_WARNING
"Warning, expected Label VOL1 not "
202 "found, treating as CDL formated Disk");