From: Roman.Hodek@informatik.uni-erlangen.de (Roman Hodek)
Date: Mon, 2 Feb 1998 22:13:15 +0100 (CET)
To: linux-m68k@lists.linux-m68k.org
Subject: L68K: Partition table code update
Sender: owner-linux-m68k@phil.uni-sb.de
Reply-To: Roman.Hodek@informatik.uni-erlangen.de


The code below brings our partition table code again in sync with the
mainstream source (2.1.84), so that the modularized partition checking
can be integrated...

Changes:

 - Move SOLARIS_X86 stuff into partbl_msdos.c, where it belongs
   (Sol/x86 partitions are a subtype of MSDOS partitions)

 - Add le{16,32}_to_cpu() calls in Sol/x86 and BSD disklabel functions.

 - Remove an #if 0 in sun partition code

 - Fix Config.in: available partition formats shouldn't depend on
   filesystems selected!

 - Config.in: SMD_DISKLABEL is obsolete

Jes: I'll send you a separate diff relative to 2.1.84 ...

Roman

------------------------------------------------------------------------------
diff -u --recursive --exclude-from=diff-excludes --new-file linux-2.1.79.orig/drivers/block/genhd.c linux-2.1.79/drivers/block/genhd.c
--- linux-2.1.79.orig/drivers/block/genhd.c	Sat Jan 24 22:17:36 1998
+++ linux-2.1.79/drivers/block/genhd.c	Mon Feb  2 21:25:07 1998
@@ -283,45 +283,6 @@
 	brelse(bh);
 	return loaded;
 }
-#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
 
 #endif /* CONFIG_KERNELD && CONFIG_FOREIGN_PARTITIONS */
 
diff -u --recursive --exclude-from=diff-excludes --new-file linux-2.1.79.orig/drivers/block/partbl_msdos.c linux-2.1.79/drivers/block/partbl_msdos.c
--- linux-2.1.79.orig/drivers/block/partbl_msdos.c	Wed Jan  7 20:18:49 1998
+++ linux-2.1.79/drivers/block/partbl_msdos.c	Mon Feb  2 21:48:46 1998
@@ -158,6 +158,47 @@
 	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 != cpu_to_le32(SOLARIS_X86_VTOC_SANE)) {
+		brelse(bh);
+		return;
+	}
+	printk(" <solaris:");
+	if(v->v_version != cpu_to_le32(1)) {
+		printk("  cannot handle version %ld vtoc>", le32_to_cpu(v->v_version));
+		brelse(bh);
+		return;
+	}
+	for(i=0; i<SOLARIS_X86_NUMSLICE; i++) {
+		s = &v->v_slice[i];
+
+		if (s->s_tag == cpu_to_le16(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, le32_to_cpu(s->s_start)+offset,
+					  le32_to_cpu(s->s_size));
+		current_minor++;
+	}
+	brelse(bh);
+	printk(" >");
+}
+#endif
+
 #ifdef CONFIG_BSD_DISKLABEL
 /* 
  * Create devices for BSD partitions listed in a disklabel, under a
@@ -174,7 +215,7 @@
 		return;
 	bh->b_state = 0;
 	l = (struct bsd_disklabel *) (bh->b_data+512);
-	if (l->d_magic != BSD_DISKMAGIC) {
+	if (l->d_magic != cpu_to_le32(BSD_DISKMAGIC)) {
 		brelse(bh);
 		return;
 	}
@@ -185,7 +226,8 @@
 			break;
 
 		if (p->p_fstype != BSD_FS_UNUSED) {
-			add_partition(hd, current_minor, p->p_offset, p->p_size);
+			add_partition(hd, current_minor, le32_to_cpu(p->p_offset),
+						  le32_to_cpu(p->p_size));
 			current_minor++;
 		}
 		p++;
@@ -325,6 +367,18 @@
 			printk(" BSD<");
 			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
 	}
diff -u --recursive --exclude-from=diff-excludes --new-file linux-2.1.79.orig/drivers/block/partbl_sun.c linux-2.1.79/drivers/block/partbl_sun.c
--- linux-2.1.79.orig/drivers/block/partbl_sun.c	Fri Oct 31 18:49:12 1997
+++ linux-2.1.79/drivers/block/partbl_sun.c	Mon Feb  2 21:26:58 1998
@@ -56,10 +56,8 @@
 	label = (struct sun_disklabel *) bh->b_data;
 	p = label->partitions;
 	if (be16_to_cpu(label->magic) != SUN_LABEL_MAGIC) {
-#if 0
 		printk("Dev %s Sun disklabel: bad magic %04x\n",
 		       kdevname(dev), be16_to_cpu(label->magic));
-#endif
 		brelse(bh);
 	    MOD_DEC_USE_COUNT;
 		return 0;
diff -u --recursive --exclude-from=diff-excludes --new-file linux-2.1.79.orig/fs/Config.in linux-2.1.79/fs/Config.in
--- linux-2.1.79.orig/fs/Config.in	Sat Jan 24 22:17:48 1998
+++ linux-2.1.79/fs/Config.in	Mon Feb  2 21:32:47 1998
@@ -124,9 +124,8 @@
   	tristate 'Mac partition support' CONFIG_MAC_PARTITION
   fi
 fi
-if [ "$CONFIG_UFS_FS" != "n" ]; then
+if [ "$CONFIG_MSDOS_PARTITION" != "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
 
