blob: 48cec7cbca176f80d8bedcf8e99f41bc977c6d4a [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * fs/partitions/osf.c
3 *
4 * Code extracted from drivers/block/genhd.c
5 *
6 * Copyright (C) 1991-1998 Linus Torvalds
7 * Re-organised Feb 1998 Russell King
8 */
9
10#include "check.h"
11#include "osf.h"
12
Tejun Heo1493bf22010-05-15 20:09:30 +020013int osf_partition(struct parsed_partitions *state)
Linus Torvalds1da177e2005-04-16 15:20:36 -070014{
15 int i;
16 int slot = 1;
17 Sector sect;
18 unsigned char *data;
19 struct disklabel {
20 __le32 d_magic;
21 __le16 d_type,d_subtype;
22 u8 d_typename[16];
23 u8 d_packname[16];
24 __le32 d_secsize;
25 __le32 d_nsectors;
26 __le32 d_ntracks;
27 __le32 d_ncylinders;
28 __le32 d_secpercyl;
29 __le32 d_secprtunit;
30 __le16 d_sparespertrack;
31 __le16 d_sparespercyl;
32 __le32 d_acylinders;
33 __le16 d_rpm, d_interleave, d_trackskew, d_cylskew;
34 __le32 d_headswitch, d_trkseek, d_flags;
35 __le32 d_drivedata[5];
36 __le32 d_spare[5];
37 __le32 d_magic2;
38 __le16 d_checksum;
39 __le16 d_npartitions;
40 __le32 d_bbsize, d_sbsize;
41 struct d_partition {
42 __le32 p_size;
43 __le32 p_offset;
44 __le32 p_fsize;
45 u8 p_fstype;
46 u8 p_frag;
47 __le16 p_cpg;
48 } d_partitions[8];
49 } * label;
50 struct d_partition * partition;
51
Tejun Heo1493bf22010-05-15 20:09:30 +020052 data = read_part_sector(state, 0, &sect);
Linus Torvalds1da177e2005-04-16 15:20:36 -070053 if (!data)
54 return -1;
55
56 label = (struct disklabel *) (data+64);
57 partition = label->d_partitions;
58 if (le32_to_cpu(label->d_magic) != DISKLABELMAGIC) {
59 put_dev_sector(sect);
60 return 0;
61 }
62 if (le32_to_cpu(label->d_magic2) != DISKLABELMAGIC) {
63 put_dev_sector(sect);
64 return 0;
65 }
66 for (i = 0 ; i < le16_to_cpu(label->d_npartitions); i++, partition++) {
67 if (slot == state->limit)
68 break;
69 if (le32_to_cpu(partition->p_size))
70 put_partition(state, slot,
71 le32_to_cpu(partition->p_offset),
72 le32_to_cpu(partition->p_size));
73 slot++;
74 }
Alexey Dobriyan9c867fb2010-08-10 18:03:14 -070075 strlcat(state->pp_buf, "\n", PAGE_SIZE);
Linus Torvalds1da177e2005-04-16 15:20:36 -070076 put_dev_sector(sect);
77 return 1;
78}