aboutsummaryrefslogtreecommitdiffstats
path: root/fs/partitions/sun.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
commit1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch)
tree0bba044c4ce775e45a88a51686b5d9f90697ea9d /fs/partitions/sun.c
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history, even though we have it. We can create a separate "historical" git archive of that later if we want to, and in the meantime it's about 3.2GB when imported into git - space that would just make the early git days unnecessarily complicated, when we don't have a lot of good infrastructure for it. Let it rip!
Diffstat (limited to 'fs/partitions/sun.c')
-rw-r--r--fs/partitions/sun.c91
1 files changed, 91 insertions, 0 deletions
diff --git a/fs/partitions/sun.c b/fs/partitions/sun.c
new file mode 100644
index 000000000000..abe91ca03edf
--- /dev/null
+++ b/fs/partitions/sun.c
@@ -0,0 +1,91 @@
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
13int sun_partition(struct parsed_partitions *state, struct block_device *bdev)
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 unsigned char spare0[14];
23 struct sun_info {
24 unsigned char spare1;
25 unsigned char id;
26 unsigned char spare2;
27 unsigned char flags;
28 } infos[8];
29 unsigned char spare[246]; /* Boot information etc. */
30 __be16 rspeed; /* Disk rotational speed */
31 __be16 pcylcount; /* Physical cylinder count */
32 __be16 sparecyl; /* extra sects per cylinder */
33 unsigned char spare2[4]; /* More magic... */
34 __be16 ilfact; /* Interleave factor */
35 __be16 ncyl; /* Data cylinder count */
36 __be16 nacyl; /* Alt. cylinder count */
37 __be16 ntrks; /* Tracks per cylinder */
38 __be16 nsect; /* Sectors per track */
39 unsigned char spare3[4]; /* Even more magic... */
40 struct sun_partition {
41 __be32 start_cylinder;
42 __be32 num_sectors;
43 } partitions[8];
44 __be16 magic; /* Magic number */
45 __be16 csum; /* Label xor'd checksum */
46 } * label;
47 struct sun_partition *p;
48 unsigned long spc;
49 char b[BDEVNAME_SIZE];
50
51 label = (struct sun_disklabel *)read_dev_sector(bdev, 0, &sect);
52 if (!label)
53 return -1;
54
55 p = label->partitions;
56 if (be16_to_cpu(label->magic) != SUN_LABEL_MAGIC) {
57/* printk(KERN_INFO "Dev %s Sun disklabel: bad magic %04x\n",
58 bdevname(bdev, b), be16_to_cpu(label->magic)); */
59 put_dev_sector(sect);
60 return 0;
61 }
62 /* Look at the checksum */
63 ush = ((__be16 *) (label+1)) - 1;
64 for (csum = 0; ush >= ((__be16 *) label);)
65 csum ^= *ush--;
66 if (csum) {
67 printk("Dev %s Sun disklabel: Csum bad, label corrupted\n",
68 bdevname(bdev, b));
69 put_dev_sector(sect);
70 return 0;
71 }
72
73 /* All Sun disks have 8 partition entries */
74 spc = be16_to_cpu(label->ntrks) * be16_to_cpu(label->nsect);
75 for (i = 0; i < 8; i++, p++) {
76 unsigned long st_sector;
77 int num_sectors;
78
79 st_sector = be32_to_cpu(p->start_cylinder) * spc;
80 num_sectors = be32_to_cpu(p->num_sectors);
81 if (num_sectors) {
82 put_partition(state, slot, st_sector, num_sectors);
83 if (label->infos[i].id == LINUX_RAID_PARTITION)
84 state->parts[slot].flags = 1;
85 }
86 slot++;
87 }
88 printk("\n");
89 put_dev_sector(sect);
90 return 1;
91}