aboutsummaryrefslogtreecommitdiffstats
path: root/fs/partitions/sysv68.c
diff options
context:
space:
mode:
authorPhilippe De Muyter <phdm@macqel.be>2007-05-08 03:29:15 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-05-08 14:15:09 -0400
commit19d0e8ce856a7628a630710aed82931ce1c7eb97 (patch)
treef2d111b8723417ddc1b136c405923a49d4fce62a /fs/partitions/sysv68.c
parente729aa16b168fb202d1a20f936028cb7c2a0278d (diff)
partition: add support for sysv68 partitions
Add support for the Motorola sysv68 disk partition (slices in motorola doc). Signed-off-by: Philippe De Muyter <phdm@macqel.be> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/partitions/sysv68.c')
-rw-r--r--fs/partitions/sysv68.c92
1 files changed, 92 insertions, 0 deletions
diff --git a/fs/partitions/sysv68.c b/fs/partitions/sysv68.c
new file mode 100644
index 000000000000..4eba27b78643
--- /dev/null
+++ b/fs/partitions/sysv68.c
@@ -0,0 +1,92 @@
1/*
2 * fs/partitions/sysv68.c
3 *
4 * Copyright (C) 2007 Philippe De Muyter <phdm@macqel.be>
5 */
6
7#include "check.h"
8#include "sysv68.h"
9
10/*
11 * Volume ID structure: on first 256-bytes sector of disk
12 */
13
14struct volumeid {
15 u8 vid_unused[248];
16 u8 vid_mac[8]; /* ASCII string "MOTOROLA" */
17};
18
19/*
20 * config block: second 256-bytes sector on disk
21 */
22
23struct dkconfig {
24 u8 ios_unused0[128];
25 __be32 ios_slcblk; /* Slice table block number */
26 __be16 ios_slccnt; /* Number of entries in slice table */
27 u8 ios_unused1[122];
28};
29
30/*
31 * combined volumeid and dkconfig block
32 */
33
34struct dkblk0 {
35 struct volumeid dk_vid;
36 struct dkconfig dk_ios;
37};
38
39/*
40 * Slice Table Structure
41 */
42
43struct slice {
44 __be32 nblocks; /* slice size (in blocks) */
45 __be32 blkoff; /* block offset of slice */
46};
47
48
49int sysv68_partition(struct parsed_partitions *state, struct block_device *bdev)
50{
51 int i, slices;
52 int slot = 1;
53 Sector sect;
54 unsigned char *data;
55 struct dkblk0 *b;
56 struct slice *slice;
57
58 data = read_dev_sector(bdev, 0, &sect);
59 if (!data)
60 return -1;
61
62 b = (struct dkblk0 *)data;
63 if (memcmp(b->dk_vid.vid_mac, "MOTOROLA", sizeof(b->dk_vid.vid_mac))) {
64 put_dev_sector(sect);
65 return 0;
66 }
67 slices = be16_to_cpu(b->dk_ios.ios_slccnt);
68 i = be32_to_cpu(b->dk_ios.ios_slcblk);
69 put_dev_sector(sect);
70
71 data = read_dev_sector(bdev, i, &sect);
72 if (!data)
73 return -1;
74
75 slices -= 1; /* last slice is the whole disk */
76 printk("sysV68: %s(s%u)", state->name, slices);
77 slice = (struct slice *)data;
78 for (i = 0; i < slices; i++, slice++) {
79 if (slot == state->limit)
80 break;
81 if (be32_to_cpu(slice->nblocks)) {
82 put_partition(state, slot,
83 be32_to_cpu(slice->blkoff),
84 be32_to_cpu(slice->nblocks));
85 printk("(s%u)", i);
86 }
87 slot++;
88 }
89 printk("\n");
90 put_dev_sector(sect);
91 return 1;
92}