diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2011-09-16 00:25:05 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2012-01-03 22:54:06 -0500 |
commit | 9be96f3fd10187f185d84cf878cf032465bcced3 (patch) | |
tree | 432a430ed9e0cbe0c18916cd3c3992f09b3feb37 /block/partitions/osf.c | |
parent | 4752bc309b7604d507c973c7b7678ac2ce10a058 (diff) |
move fs/partitions to block/
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'block/partitions/osf.c')
-rw-r--r-- | block/partitions/osf.c | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/block/partitions/osf.c b/block/partitions/osf.c new file mode 100644 index 00000000000..764b86a0196 --- /dev/null +++ b/block/partitions/osf.c | |||
@@ -0,0 +1,86 @@ | |||
1 | /* | ||
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 | |||
13 | #define MAX_OSF_PARTITIONS 18 | ||
14 | |||
15 | int osf_partition(struct parsed_partitions *state) | ||
16 | { | ||
17 | int i; | ||
18 | int slot = 1; | ||
19 | unsigned int npartitions; | ||
20 | Sector sect; | ||
21 | unsigned char *data; | ||
22 | struct disklabel { | ||
23 | __le32 d_magic; | ||
24 | __le16 d_type,d_subtype; | ||
25 | u8 d_typename[16]; | ||
26 | u8 d_packname[16]; | ||
27 | __le32 d_secsize; | ||
28 | __le32 d_nsectors; | ||
29 | __le32 d_ntracks; | ||
30 | __le32 d_ncylinders; | ||
31 | __le32 d_secpercyl; | ||
32 | __le32 d_secprtunit; | ||
33 | __le16 d_sparespertrack; | ||
34 | __le16 d_sparespercyl; | ||
35 | __le32 d_acylinders; | ||
36 | __le16 d_rpm, d_interleave, d_trackskew, d_cylskew; | ||
37 | __le32 d_headswitch, d_trkseek, d_flags; | ||
38 | __le32 d_drivedata[5]; | ||
39 | __le32 d_spare[5]; | ||
40 | __le32 d_magic2; | ||
41 | __le16 d_checksum; | ||
42 | __le16 d_npartitions; | ||
43 | __le32 d_bbsize, d_sbsize; | ||
44 | struct d_partition { | ||
45 | __le32 p_size; | ||
46 | __le32 p_offset; | ||
47 | __le32 p_fsize; | ||
48 | u8 p_fstype; | ||
49 | u8 p_frag; | ||
50 | __le16 p_cpg; | ||
51 | } d_partitions[MAX_OSF_PARTITIONS]; | ||
52 | } * label; | ||
53 | struct d_partition * partition; | ||
54 | |||
55 | data = read_part_sector(state, 0, §); | ||
56 | if (!data) | ||
57 | return -1; | ||
58 | |||
59 | label = (struct disklabel *) (data+64); | ||
60 | partition = label->d_partitions; | ||
61 | if (le32_to_cpu(label->d_magic) != DISKLABELMAGIC) { | ||
62 | put_dev_sector(sect); | ||
63 | return 0; | ||
64 | } | ||
65 | if (le32_to_cpu(label->d_magic2) != DISKLABELMAGIC) { | ||
66 | put_dev_sector(sect); | ||
67 | return 0; | ||
68 | } | ||
69 | npartitions = le16_to_cpu(label->d_npartitions); | ||
70 | if (npartitions > MAX_OSF_PARTITIONS) { | ||
71 | put_dev_sector(sect); | ||
72 | return 0; | ||
73 | } | ||
74 | for (i = 0 ; i < npartitions; i++, partition++) { | ||
75 | if (slot == state->limit) | ||
76 | break; | ||
77 | if (le32_to_cpu(partition->p_size)) | ||
78 | put_partition(state, slot, | ||
79 | le32_to_cpu(partition->p_offset), | ||
80 | le32_to_cpu(partition->p_size)); | ||
81 | slot++; | ||
82 | } | ||
83 | strlcat(state->pp_buf, "\n", PAGE_SIZE); | ||
84 | put_dev_sector(sect); | ||
85 | return 1; | ||
86 | } | ||