Patch for 2.1.76 to read solaris x86 vtoc information

James Bottomley (James.Bottomley@columbiasc.ncr.com)
Tue, 30 Dec 1997 09:50:52 -0600


This is a multipart MIME message.

--==_Exmh_4593505060
Content-Type: text/plain; charset=us-ascii

for those of us who dual boot solaris and linux on intel, The attached patch
for 2.1.76 will allow linux to recognise the solaris disk slice information.
You can then mount solaris slices using `mount -t ufs'

Since all the solaris slices appear as extended partitions, the kernel output
tries to tell you which slice went where by preceeding each device assignment
with [s%d] where %d is the actual slice number.

I've only tested this with solaris 2.6, but see no reason why it shouldn't
work with earlier versions (the vtoc structure version number is still 1).

James Bottomley
james@bpgc.com

--==_Exmh_4593505060
Content-Type: text/plain ; name="linux.solaris.diff"; charset=us-ascii
Content-Description: linux.solaris.diff
Content-Disposition: attachment; filename="linux.solaris.diff"

--- 1.1 1997/12/29 23:26:35
+++ ./fs/Config.in 1997/12/29 23:27:00
@@ -66,6 +66,7 @@
if [ "$CONFIG_UFS_FS" != "n" ]; then
bool 'BSD disklabel (FreeBSD partition tables) support' CONFIG_BSD_DISKLABEL
bool 'SMD disklabel (Sun partition tables) support' CONFIG_SMD_DISKLABEL
+ bool 'Solaris (x86) partition table support' CONFIG_SOLARIS_X86_PARTITION
fi
bool 'Macintosh partition map support' CONFIG_MAC_PARTITION
endmenu
--- 1.1 1997/12/29 23:40:23
+++ ./include/linux/genhd.h 1997/12/30 00:36:19
@@ -25,6 +25,11 @@
confused about extended/logical partitions starting past cylinder 1023. */
#define DOS_EXTENDED_PARTITION 5
#define LINUX_EXTENDED_PARTITION 0x85
+#define LINUX_SWAP_PARTITION 0x82
+
+#ifdef CONFIG_SOLARIS_X86_PARTITION
+#define SOLARIS_X86_PARTITION LINUX_SWAP_PARTITION
+#endif

#define DM6_PARTITION 0x54 /* has DDO: use xlated geom & offset */
#define EZD_PARTITION 0x55 /* EZ-DRIVE: same as DM6 (we think) */
@@ -65,6 +70,34 @@
void *real_devices; /* internal use */
struct gendisk *next;
};
+
+#ifdef CONFIG_SOLARIS_X86_PARTITION
+
+#define SOLARIS_X86_NUMSLICE 8
+#define SOLARIS_X86_VTOC_SANE (0x600DDEEEUL)
+
+struct solaris_x86_slice {
+ ushort s_tag; /* ID tag of partition */
+ ushort s_flag; /* permision flags */
+ daddr_t s_start; /* start sector no of partition */
+ long s_size; /* # of blocks in partition */
+};
+
+struct solaris_x86_vtoc {
+ unsigned long v_bootinfo[3]; /* info needed by mboot (unsupported) */
+ unsigned long v_sanity; /* to verify vtoc sanity */
+ unsigned long v_version; /* layout version */
+ char v_volume[8]; /* volume name */
+ ushort v_sectorsz; /* sector size in bytes */
+ ushort v_nparts; /* number of partitions */
+ unsigned long v_reserved[10]; /* free space */
+ struct solaris_x86_slice
+ v_slice[SOLARIS_X86_NUMSLICE]; /* slice headers */
+ time_t timestamp[SOLARIS_X86_NUMSLICE]; /* timestamp (unsupported) */
+ char v_asciilabel[128]; /* for compatibility */
+};
+
+#endif /* CONFIG_SOLARIS_X86_PARTITION */

#ifdef CONFIG_BSD_DISKLABEL
/*
--- 1.1 1997/12/29 23:22:34
+++ ./drivers/block/genhd.c 1997/12/30 02:05:06
@@ -254,6 +254,45 @@
done:
brelse(bh);
}
+#ifdef CONFIG_SOLARIS_X86_PARTITION
+static void
+solaris_x86_partition(struct gendisk *hd, kdev_t dev, long offset) {
+
+ struct buffer_head *bh;
+ struct solaris_x86_vtoc *v;
+ struct solaris_x86_slice *s;
+ int i;
+
+ if(!(bh = bread(dev, 0, get_ptable_blocksize(dev))))
+ return;
+ v = (struct solaris_x86_vtoc *)(bh->b_data + 512);
+ if(v->v_sanity != SOLARIS_X86_VTOC_SANE) {
+ brelse(bh);
+ return;
+ }
+ printk(" <solaris:");
+ if(v->v_version != 1) {
+ printk(" cannot handle version %ld vtoc>", v->v_version);
+ brelse(bh);
+ return;
+ }
+ for(i=0; i<SOLARIS_X86_NUMSLICE; i++) {
+ s = &v->v_slice[i];
+
+ if (s->s_tag == 0)
+ continue;
+ printk(" [s%d]", i);
+ /* solaris partitions are relative to current MS-DOS
+ * one but add_partition starts relative to sector
+ * zero of the disk. Therefore, must add the offset
+ * of the current partition */
+ add_partition(hd, current_minor, s->s_start+offset, s->s_size);
+ current_minor++;
+ }
+ brelse(bh);
+ printk(" >");
+}
+#endif

#ifdef CONFIG_BSD_DISKLABEL
/*
@@ -418,6 +457,18 @@
printk(" <");
bsd_disklabel_partition(hd, MKDEV(hd->major, minor));
printk(" >");
+ }
+#endif
+#ifdef CONFIG_SOLARIS_X86_PARTITION
+
+ /* james@bpgc.com: Solaris has a nasty indicator: 0x82
+ * which also means linux swap. For that reason, all
+ * of the prints are done inside the
+ * solaris_x86_partition routine */
+
+ if(SYS_IND(p) == SOLARIS_X86_PARTITION) {
+ solaris_x86_partition(hd, MKDEV(hd->major, minor),
+ first_sector+START_SECT(p));
}
#endif
}

--==_Exmh_4593505060--