]>
git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blob - fs/partitions/ibm.c
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
;
48 dasd_information_t
*info
;
49 struct hd_geometry
*geo
;
53 struct vtoc_volume_label vol
;
54 struct vtoc_cms_label cms
;
59 blocksize
= bdev_hardsect_size(bdev
);
62 i_size
= i_size_read(bdev
->bd_inode
);
66 if ((info
= kmalloc(sizeof(dasd_information_t
), GFP_KERNEL
)) == NULL
)
68 if ((geo
= kmalloc(sizeof(struct hd_geometry
), GFP_KERNEL
)) == NULL
)
70 if ((label
= kmalloc(sizeof(union label_t
), GFP_KERNEL
)) == NULL
)
73 if (ioctl_by_bdev(bdev
, BIODASDINFO
, (unsigned long)info
) != 0 ||
74 ioctl_by_bdev(bdev
, HDIO_GETGEO
, (unsigned long)geo
) != 0)
78 * Get volume label, extract name and type.
80 data
= read_dev_sector(bdev
, info
->label_block
*(blocksize
/512), §
);
84 strncpy (type
, data
, 4);
85 if ((!info
->FBA_layout
) && (!strcmp(info
->type
, "ECKD")))
86 strncpy(name
, data
+ 8, 6);
88 strncpy(name
, data
+ 4, 6);
89 memcpy(label
, data
, sizeof(union label_t
));
96 * Three different types: CMS1, VOL1 and LNX1/unlabeled
98 if (strncmp(type
, "CMS1", 4) == 0) {
100 * VM style CMS1 labeled disk
102 if (label
->cms
.disk_offset
!= 0) {
103 printk("CMS1/%8s(MDSK):", name
);
104 /* disk is reserved minidisk */
105 blocksize
= label
->cms
.block_size
;
106 offset
= label
->cms
.disk_offset
;
107 size
= (label
->cms
.block_count
- 1) * (blocksize
>> 9);
109 printk("CMS1/%8s:", name
);
110 offset
= (info
->label_block
+ 1);
113 put_partition(state
, 1, offset
*(blocksize
>> 9),
114 size
-offset
*(blocksize
>> 9));
115 } else if ((strncmp(type
, "VOL1", 4) == 0) &&
116 (!info
->FBA_layout
) && (!strcmp(info
->type
, "ECKD"))) {
118 * New style VOL1 labeled disk
123 printk("VOL1/%8s:", name
);
125 /* get block number and read then go through format1 labels */
126 blk
= cchhb2blk(&label
->vol
.vtoc
, geo
) + 1;
128 while ((data
= read_dev_sector(bdev
, blk
*(blocksize
/512),
130 struct vtoc_format1_label f1
;
132 memcpy(&f1
, data
, sizeof(struct vtoc_format1_label
));
133 put_dev_sector(sect
);
135 /* skip FMT4 / FMT5 / FMT7 labels */
136 if (f1
.DS1FMTID
== _ascebc
['4']
137 || f1
.DS1FMTID
== _ascebc
['5']
138 || f1
.DS1FMTID
== _ascebc
['7']) {
143 /* only FMT1 valid at this point */
144 if (f1
.DS1FMTID
!= _ascebc
['1'])
147 /* OK, we got valid partition data */
148 offset
= cchh2blk(&f1
.DS1EXT1
.llimit
, geo
);
149 size
= cchh2blk(&f1
.DS1EXT1
.ulimit
, geo
) -
150 offset
+ geo
->sectors
;
151 if (counter
>= state
->limit
)
153 put_partition(state
, counter
+ 1,
154 offset
* (blocksize
>> 9),
155 size
* (blocksize
>> 9));
161 * Old style LNX1 or unlabeled disk
163 if (strncmp(type
, "LNX1", 4) == 0)
164 printk ("LNX1/%8s:", name
);
166 printk("(nonl)/%8s:", name
);
167 offset
= (info
->label_block
+ 1);
169 put_partition(state
, 1, offset
*(blocksize
>> 9),
170 size
-offset
*(blocksize
>> 9));