[PATCH] Sun/Solaris VTOC table corrections

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Add in fix to prevent the VTOC table being used if it is not present
(it was not implemented until Solaris 2.x so SunOS 4.1.x will not have
valid VTOC data) and correct the Solaris x86 number of partitions (slices).

Signed-off-by: Mark Fortescue <mark@xxxxxxxxxxxxxxxxxx>
---
Patch attached in case it gets mangled.
diff -ruNpd -x .git -x .gitignore -x .mailmap linux-2.6/fs/partitions/sun.c linux-test/fs/partitions/sun.c
--- linux-2.6/fs/partitions/sun.c	2007-07-24 22:47:22.000000000 +0100
+++ linux-test/fs/partitions/sun.c	2007-07-12 09:34:16.000000000 +0100
@@ -19,24 +19,35 @@ int sun_partition(struct parsed_partitio
 	Sector sect;
 	struct sun_disklabel {
 		unsigned char info[128];   /* Informative text string */
-		unsigned char spare0[14];
-		struct sun_info {
-			unsigned char spare1;
-			unsigned char id;
-			unsigned char spare2;
-			unsigned char flags;
-		} infos[8];
-		unsigned char spare[246];  /* Boot information etc. */
+		struct sun_vtoc {
+		    __be32 version;     /* Layout version */
+		    char   volume[8];   /* Volume name */
+		    __be16 nparts;      /* Number of partitions */
+		    struct sun_info {           /* Partition hdrs, sec 2 */
+			__be16 id;
+			__be16 flags;
+		    } infos[8];
+		    __be16 padding;      /* Alignment padding */
+		    __be32 bootinfo[3];  /* Info needed by mboot */
+		    __be32 sanity;       /* To verify vtoc sanity */
+		    __be32 reserved[10]; /* Free space */
+		    __be32 timestamp[8]; /* Partition timestamp */
+		} vtoc;
+		__be32 write_reinstruct; /* sectors to skip, writes */
+		__be32 read_reinstruct;  /* sectors to skip, reads */
+		unsigned char spare[148]; /* Padding */
 		__be16 rspeed;     /* Disk rotational speed */
 		__be16 pcylcount;  /* Physical cylinder count */
 		__be16 sparecyl;   /* extra sects per cylinder */
-		unsigned char spare2[4];   /* More magic... */
+		__be16 obs1;       /* gap1 */
+		__be16 obs2;       /* gap2 */
 		__be16 ilfact;     /* Interleave factor */
 		__be16 ncyl;       /* Data cylinder count */
 		__be16 nacyl;      /* Alt. cylinder count */
 		__be16 ntrks;      /* Tracks per cylinder */
 		__be16 nsect;      /* Sectors per track */
-		unsigned char spare3[4];   /* Even more magic... */
+		__be16 obs3;       /* bhead - Label head offset */
+		__be16 obs4;       /* ppart - Physical Partition */
 		struct sun_partition {
 			__be32 start_cylinder;
 			__be32 num_sectors;
@@ -81,10 +92,13 @@ int sun_partition(struct parsed_partitio
 		if (num_sectors) {
 			put_partition(state, slot, st_sector, num_sectors);
 			state->parts[slot].flags = 0;
-			if (label->infos[i].id == LINUX_RAID_PARTITION)
-				state->parts[slot].flags |= ADDPART_FLAG_RAID;
-			if (label->infos[i].id == SUN_WHOLE_DISK)
-				state->parts[slot].flags |= ADDPART_FLAG_WHOLEDISK;
+			/* Need to validate the VTOC before we use it */
+			if (be32_to_cpu(label->vtoc.sanity) == SUN_VTOC_SANITY) {
+				if (be16_to_cpu(label->vtoc.infos[i].id) == LINUX_RAID_PARTITION)
+					state->parts[slot].flags |= ADDPART_FLAG_RAID;
+				else if (be16_to_cpu(label->vtoc.infos[i].id) == SUN_WHOLE_DISK)
+					state->parts[slot].flags |= ADDPART_FLAG_WHOLEDISK;
+			}
 		}
 		slot++;
 	}
diff -ruNpd -x .git -x .gitignore -x .mailmap linux-2.6/fs/partitions/sun.h linux-test/fs/partitions/sun.h
--- linux-2.6/fs/partitions/sun.h	2007-04-30 01:29:02.000000000 +0100
+++ linux-test/fs/partitions/sun.h	2007-07-12 09:34:16.000000000 +0100
@@ -3,5 +3,6 @@
  */

 #define SUN_LABEL_MAGIC          0xDABE
+#define SUN_VTOC_SANITY          0x600DDEEE

 int sun_partition(struct parsed_partitions *state, struct block_device *bdev);
diff -ruNpd -x .git -x .gitignore -x .mailmap linux-2.6/include/linux/genhd.h linux-test/include/linux/genhd.h
--- linux-2.6/include/linux/genhd.h	2007-07-24 22:47:26.000000000 +0100
+++ linux-test/include/linux/genhd.h	2007-07-12 09:34:16.000000000 +0100
@@ -264,7 +264,7 @@ static inline void set_capacity(struct g

 #ifdef CONFIG_SOLARIS_X86_PARTITION

-#define SOLARIS_X86_NUMSLICE	8
+#define SOLARIS_X86_NUMSLICE	16
 #define SOLARIS_X86_VTOC_SANE	(0x600DDEEEUL)

 struct solaris_x86_slice {
From: Mark Fortescue <mark@xxxxxxxxxxxxxxxxxx>

Add in fix to prevent the VTOC table being used if it is not present
(it was not implemented until Solaris 2.x so SunOS 4.1.x will not have
valid VTOC data) and correct the Solaris x86 number of partitions (slices).

Signed-off-by: Mark Fortescue <mark@xxxxxxxxxxxxxxxxxx>
---
diff -ruNpd -x .git -x .gitignore -x .mailmap linux-2.6/fs/partitions/sun.c linux-test/fs/partitions/sun.c
--- linux-2.6/fs/partitions/sun.c	2007-07-24 22:47:22.000000000 +0100
+++ linux-test/fs/partitions/sun.c	2007-07-12 09:34:16.000000000 +0100
@@ -19,24 +19,35 @@ int sun_partition(struct parsed_partitio
 	Sector sect;
 	struct sun_disklabel {
 		unsigned char info[128];   /* Informative text string */
-		unsigned char spare0[14];
-		struct sun_info {
-			unsigned char spare1;
-			unsigned char id;
-			unsigned char spare2;
-			unsigned char flags;
-		} infos[8];
-		unsigned char spare[246];  /* Boot information etc. */
+		struct sun_vtoc {
+		    __be32 version;     /* Layout version */
+		    char   volume[8];   /* Volume name */
+		    __be16 nparts;      /* Number of partitions */
+		    struct sun_info {           /* Partition hdrs, sec 2 */
+			__be16 id;
+			__be16 flags;
+		    } infos[8];
+		    __be16 padding;      /* Alignment padding */
+		    __be32 bootinfo[3];  /* Info needed by mboot */
+		    __be32 sanity;       /* To verify vtoc sanity */
+		    __be32 reserved[10]; /* Free space */
+		    __be32 timestamp[8]; /* Partition timestamp */
+		} vtoc;
+		__be32 write_reinstruct; /* sectors to skip, writes */
+		__be32 read_reinstruct;  /* sectors to skip, reads */
+		unsigned char spare[148]; /* Padding */
 		__be16 rspeed;     /* Disk rotational speed */
 		__be16 pcylcount;  /* Physical cylinder count */
 		__be16 sparecyl;   /* extra sects per cylinder */
-		unsigned char spare2[4];   /* More magic... */
+		__be16 obs1;       /* gap1 */
+		__be16 obs2;       /* gap2 */
 		__be16 ilfact;     /* Interleave factor */
 		__be16 ncyl;       /* Data cylinder count */
 		__be16 nacyl;      /* Alt. cylinder count */
 		__be16 ntrks;      /* Tracks per cylinder */
 		__be16 nsect;      /* Sectors per track */
-		unsigned char spare3[4];   /* Even more magic... */
+		__be16 obs3;       /* bhead - Label head offset */
+		__be16 obs4;       /* ppart - Physical Partition */
 		struct sun_partition {
 			__be32 start_cylinder;
 			__be32 num_sectors;
@@ -81,10 +92,13 @@ int sun_partition(struct parsed_partitio
 		if (num_sectors) {
 			put_partition(state, slot, st_sector, num_sectors);
 			state->parts[slot].flags = 0;
-			if (label->infos[i].id == LINUX_RAID_PARTITION)
-				state->parts[slot].flags |= ADDPART_FLAG_RAID;
-			if (label->infos[i].id == SUN_WHOLE_DISK)
-				state->parts[slot].flags |= ADDPART_FLAG_WHOLEDISK;
+			/* Need to validate the VTOC before we use it */
+			if (be32_to_cpu(label->vtoc.sanity) == SUN_VTOC_SANITY) {
+				if (be16_to_cpu(label->vtoc.infos[i].id) == LINUX_RAID_PARTITION)
+					state->parts[slot].flags |= ADDPART_FLAG_RAID;
+				else if (be16_to_cpu(label->vtoc.infos[i].id) == SUN_WHOLE_DISK)
+					state->parts[slot].flags |= ADDPART_FLAG_WHOLEDISK;
+			}
 		}
 		slot++;
 	}
diff -ruNpd -x .git -x .gitignore -x .mailmap linux-2.6/fs/partitions/sun.h linux-test/fs/partitions/sun.h
--- linux-2.6/fs/partitions/sun.h	2007-04-30 01:29:02.000000000 +0100
+++ linux-test/fs/partitions/sun.h	2007-07-12 09:34:16.000000000 +0100
@@ -3,5 +3,6 @@
  */
 
 #define SUN_LABEL_MAGIC          0xDABE
+#define SUN_VTOC_SANITY          0x600DDEEE
 
 int sun_partition(struct parsed_partitions *state, struct block_device *bdev);
diff -ruNpd -x .git -x .gitignore -x .mailmap linux-2.6/include/linux/genhd.h linux-test/include/linux/genhd.h
--- linux-2.6/include/linux/genhd.h	2007-07-24 22:47:26.000000000 +0100
+++ linux-test/include/linux/genhd.h	2007-07-12 09:34:16.000000000 +0100
@@ -264,7 +264,7 @@ static inline void set_capacity(struct g
 
 #ifdef CONFIG_SOLARIS_X86_PARTITION
 
-#define SOLARIS_X86_NUMSLICE	8
+#define SOLARIS_X86_NUMSLICE	16
 #define SOLARIS_X86_VTOC_SANE	(0x600DDEEEUL)
 
 struct solaris_x86_slice {

[Index of Archives]     [Kernel Development]     [DCCP]     [Linux ARM Development]     [Linux]     [Photo]     [Yosemite Help]     [Linux ARM Kernel]     [Linux SCSI]     [Linux x86_64]     [Linux Hams]

  Powered by Linux