diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2012-01-08 15:19:57 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-01-08 15:19:57 -0500 |
commit | 972b2c719990f91eb3b2310d44ef8a2d38955a14 (patch) | |
tree | b25a250ec5bec4b7b6355d214642d8b57c5cab32 /block/partitions/sun.c | |
parent | 02550d61f49266930e674286379d3601006b2893 (diff) | |
parent | c3aa077648e147783a7a53b409578234647db853 (diff) |
Merge branch 'for-linus2' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
* 'for-linus2' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: (165 commits)
reiserfs: Properly display mount options in /proc/mounts
vfs: prevent remount read-only if pending removes
vfs: count unlinked inodes
vfs: protect remounting superblock read-only
vfs: keep list of mounts for each superblock
vfs: switch ->show_options() to struct dentry *
vfs: switch ->show_path() to struct dentry *
vfs: switch ->show_devname() to struct dentry *
vfs: switch ->show_stats to struct dentry *
switch security_path_chmod() to struct path *
vfs: prefer ->dentry->d_sb to ->mnt->mnt_sb
vfs: trim includes a bit
switch mnt_namespace ->root to struct mount
vfs: take /proc/*/mounts and friends to fs/proc_namespace.c
vfs: opencode mntget() mnt_set_mountpoint()
vfs: spread struct mount - remaining argument of next_mnt()
vfs: move fsnotify junk to struct mount
vfs: move mnt_devname
vfs: move mnt_list to struct mount
vfs: switch pnode.h macros to struct mount *
...
Diffstat (limited to 'block/partitions/sun.c')
-rw-r--r-- | block/partitions/sun.c | 122 |
1 files changed, 122 insertions, 0 deletions
diff --git a/block/partitions/sun.c b/block/partitions/sun.c new file mode 100644 index 000000000000..b5b6fcfb3d36 --- /dev/null +++ b/block/partitions/sun.c | |||
@@ -0,0 +1,122 @@ | |||
1 | /* | ||
2 | * fs/partitions/sun.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 "sun.h" | ||
12 | |||
13 | int sun_partition(struct parsed_partitions *state) | ||
14 | { | ||
15 | int i; | ||
16 | __be16 csum; | ||
17 | int slot = 1; | ||
18 | __be16 *ush; | ||
19 | Sector sect; | ||
20 | struct sun_disklabel { | ||
21 | unsigned char info[128]; /* Informative text string */ | ||
22 | struct sun_vtoc { | ||
23 | __be32 version; /* Layout version */ | ||
24 | char volume[8]; /* Volume name */ | ||
25 | __be16 nparts; /* Number of partitions */ | ||
26 | struct sun_info { /* Partition hdrs, sec 2 */ | ||
27 | __be16 id; | ||
28 | __be16 flags; | ||
29 | } infos[8]; | ||
30 | __be16 padding; /* Alignment padding */ | ||
31 | __be32 bootinfo[3]; /* Info needed by mboot */ | ||
32 | __be32 sanity; /* To verify vtoc sanity */ | ||
33 | __be32 reserved[10]; /* Free space */ | ||
34 | __be32 timestamp[8]; /* Partition timestamp */ | ||
35 | } vtoc; | ||
36 | __be32 write_reinstruct; /* sectors to skip, writes */ | ||
37 | __be32 read_reinstruct; /* sectors to skip, reads */ | ||
38 | unsigned char spare[148]; /* Padding */ | ||
39 | __be16 rspeed; /* Disk rotational speed */ | ||
40 | __be16 pcylcount; /* Physical cylinder count */ | ||
41 | __be16 sparecyl; /* extra sects per cylinder */ | ||
42 | __be16 obs1; /* gap1 */ | ||
43 | __be16 obs2; /* gap2 */ | ||
44 | __be16 ilfact; /* Interleave factor */ | ||
45 | __be16 ncyl; /* Data cylinder count */ | ||
46 | __be16 nacyl; /* Alt. cylinder count */ | ||
47 | __be16 ntrks; /* Tracks per cylinder */ | ||
48 | __be16 nsect; /* Sectors per track */ | ||
49 | __be16 obs3; /* bhead - Label head offset */ | ||
50 | __be16 obs4; /* ppart - Physical Partition */ | ||
51 | struct sun_partition { | ||
52 | __be32 start_cylinder; | ||
53 | __be32 num_sectors; | ||
54 | } partitions[8]; | ||
55 | __be16 magic; /* Magic number */ | ||
56 | __be16 csum; /* Label xor'd checksum */ | ||
57 | } * label; | ||
58 | struct sun_partition *p; | ||
59 | unsigned long spc; | ||
60 | char b[BDEVNAME_SIZE]; | ||
61 | int use_vtoc; | ||
62 | int nparts; | ||
63 | |||
64 | label = read_part_sector(state, 0, §); | ||
65 | if (!label) | ||
66 | return -1; | ||
67 | |||
68 | p = label->partitions; | ||
69 | if (be16_to_cpu(label->magic) != SUN_LABEL_MAGIC) { | ||
70 | /* printk(KERN_INFO "Dev %s Sun disklabel: bad magic %04x\n", | ||
71 | bdevname(bdev, b), be16_to_cpu(label->magic)); */ | ||
72 | put_dev_sector(sect); | ||
73 | return 0; | ||
74 | } | ||
75 | /* Look at the checksum */ | ||
76 | ush = ((__be16 *) (label+1)) - 1; | ||
77 | for (csum = 0; ush >= ((__be16 *) label);) | ||
78 | csum ^= *ush--; | ||
79 | if (csum) { | ||
80 | printk("Dev %s Sun disklabel: Csum bad, label corrupted\n", | ||
81 | bdevname(state->bdev, b)); | ||
82 | put_dev_sector(sect); | ||
83 | return 0; | ||
84 | } | ||
85 | |||
86 | /* Check to see if we can use the VTOC table */ | ||
87 | use_vtoc = ((be32_to_cpu(label->vtoc.sanity) == SUN_VTOC_SANITY) && | ||
88 | (be32_to_cpu(label->vtoc.version) == 1) && | ||
89 | (be16_to_cpu(label->vtoc.nparts) <= 8)); | ||
90 | |||
91 | /* Use 8 partition entries if not specified in validated VTOC */ | ||
92 | nparts = (use_vtoc) ? be16_to_cpu(label->vtoc.nparts) : 8; | ||
93 | |||
94 | /* | ||
95 | * So that old Linux-Sun partitions continue to work, | ||
96 | * alow the VTOC to be used under the additional condition ... | ||
97 | */ | ||
98 | use_vtoc = use_vtoc || !(label->vtoc.sanity || | ||
99 | label->vtoc.version || label->vtoc.nparts); | ||
100 | spc = be16_to_cpu(label->ntrks) * be16_to_cpu(label->nsect); | ||
101 | for (i = 0; i < nparts; i++, p++) { | ||
102 | unsigned long st_sector; | ||
103 | unsigned int num_sectors; | ||
104 | |||
105 | st_sector = be32_to_cpu(p->start_cylinder) * spc; | ||
106 | num_sectors = be32_to_cpu(p->num_sectors); | ||
107 | if (num_sectors) { | ||
108 | put_partition(state, slot, st_sector, num_sectors); | ||
109 | state->parts[slot].flags = 0; | ||
110 | if (use_vtoc) { | ||
111 | if (be16_to_cpu(label->vtoc.infos[i].id) == LINUX_RAID_PARTITION) | ||
112 | state->parts[slot].flags |= ADDPART_FLAG_RAID; | ||
113 | else if (be16_to_cpu(label->vtoc.infos[i].id) == SUN_WHOLE_DISK) | ||
114 | state->parts[slot].flags |= ADDPART_FLAG_WHOLEDISK; | ||
115 | } | ||
116 | } | ||
117 | slot++; | ||
118 | } | ||
119 | strlcat(state->pp_buf, "\n", PAGE_SIZE); | ||
120 | put_dev_sector(sect); | ||
121 | return 1; | ||
122 | } | ||