]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
partition: add support for sysv68 partitions
authorPhilippe De Muyter <phdm@macqel.be>
Tue, 8 May 2007 07:29:15 +0000 (00:29 -0700)
committerLinus Torvalds <torvalds@woody.linux-foundation.org>
Tue, 8 May 2007 18:15:09 +0000 (11:15 -0700)
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>
fs/partitions/Kconfig
fs/partitions/Makefile
fs/partitions/check.c
fs/partitions/sysv68.c [new file with mode: 0644]
fs/partitions/sysv68.h [new file with mode: 0644]

index 6e8bb66fe61957afe51b4e7eb00004ba20b0ba96..01207042048b993201b0799b82c6a198ab73001f 100644 (file)
@@ -236,3 +236,12 @@ config EFI_PARTITION
        help
          Say Y here if you would like to use hard disks under Linux which
          were partitioned using EFI GPT.
+
+config SYSV68_PARTITION
+       bool "SYSV68 partition table support" if PARTITION_ADVANCED
+       default y if M68K
+       help
+         Say Y here if you would like to be able to read the hard disk
+         partition table format used by Motorola Delta machines (using
+         sysv68).
+         Otherwise, say N.
index 67e665fdb7fccbde923238532d49f192931d43f9..03af8eac51da81bf4f89cc49d7d9ca466d38c54b 100644 (file)
@@ -17,3 +17,4 @@ obj-$(CONFIG_ULTRIX_PARTITION) += ultrix.o
 obj-$(CONFIG_IBM_PARTITION) += ibm.o
 obj-$(CONFIG_EFI_PARTITION) += efi.o
 obj-$(CONFIG_KARMA_PARTITION) += karma.o
+obj-$(CONFIG_SYSV68_PARTITION) += sysv68.o
index 6b9dae3f0e6c1d493f6b3990c2a1b5d18db3b8c5..9a3a058f355365405911c3f1173209cfac30150d 100644 (file)
@@ -34,6 +34,7 @@
 #include "ultrix.h"
 #include "efi.h"
 #include "karma.h"
+#include "sysv68.h"
 
 #ifdef CONFIG_BLK_DEV_MD
 extern void md_autodetect_dev(dev_t dev);
@@ -104,6 +105,9 @@ static int (*check_part[])(struct parsed_partitions *, struct block_device *) =
 #endif
 #ifdef CONFIG_KARMA_PARTITION
        karma_partition,
+#endif
+#ifdef CONFIG_SYSV68_PARTITION
+       sysv68_partition,
 #endif
        NULL
 };
diff --git a/fs/partitions/sysv68.c b/fs/partitions/sysv68.c
new file mode 100644 (file)
index 0000000..4eba27b
--- /dev/null
@@ -0,0 +1,92 @@
+/*
+ *  fs/partitions/sysv68.c
+ *
+ *  Copyright (C) 2007 Philippe De Muyter <phdm@macqel.be>
+ */
+
+#include "check.h"
+#include "sysv68.h"
+
+/*
+ *     Volume ID structure: on first 256-bytes sector of disk
+ */
+
+struct volumeid {
+       u8      vid_unused[248];
+       u8      vid_mac[8];     /* ASCII string "MOTOROLA" */
+};
+
+/*
+ *     config block: second 256-bytes sector on disk
+ */
+
+struct dkconfig {
+       u8      ios_unused0[128];
+       __be32  ios_slcblk;     /* Slice table block number */
+       __be16  ios_slccnt;     /* Number of entries in slice table */
+       u8      ios_unused1[122];
+};
+
+/*
+ *     combined volumeid and dkconfig block
+ */
+
+struct dkblk0 {
+       struct volumeid dk_vid;
+       struct dkconfig dk_ios;
+};
+
+/*
+ *     Slice Table Structure
+ */
+
+struct slice {
+       __be32  nblocks;                /* slice size (in blocks) */
+       __be32  blkoff;                 /* block offset of slice */
+};
+
+
+int sysv68_partition(struct parsed_partitions *state, struct block_device *bdev)
+{
+       int i, slices;
+       int slot = 1;
+       Sector sect;
+       unsigned char *data;
+       struct dkblk0 *b;
+       struct slice *slice;
+
+       data = read_dev_sector(bdev, 0, &sect);
+       if (!data)
+               return -1;
+
+       b = (struct dkblk0 *)data;
+       if (memcmp(b->dk_vid.vid_mac, "MOTOROLA", sizeof(b->dk_vid.vid_mac))) {
+               put_dev_sector(sect);
+               return 0;
+       }
+       slices = be16_to_cpu(b->dk_ios.ios_slccnt);
+       i = be32_to_cpu(b->dk_ios.ios_slcblk);
+       put_dev_sector(sect);
+
+       data = read_dev_sector(bdev, i, &sect);
+       if (!data)
+               return -1;
+
+       slices -= 1; /* last slice is the whole disk */
+       printk("sysV68: %s(s%u)", state->name, slices);
+       slice = (struct slice *)data;
+       for (i = 0; i < slices; i++, slice++) {
+               if (slot == state->limit)
+                       break;
+               if (be32_to_cpu(slice->nblocks)) {
+                       put_partition(state, slot,
+                               be32_to_cpu(slice->blkoff),
+                               be32_to_cpu(slice->nblocks));
+                       printk("(s%u)", i);
+               }
+               slot++;
+       }
+       printk("\n");
+       put_dev_sector(sect);
+       return 1;
+}
diff --git a/fs/partitions/sysv68.h b/fs/partitions/sysv68.h
new file mode 100644 (file)
index 0000000..fa733f6
--- /dev/null
@@ -0,0 +1 @@
+extern int sysv68_partition(struct parsed_partitions *state, struct block_device *bdev);