Re: [PATCH] Sun/Solaris VTOC table corrections

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

 



On Wed, Jul 25, 2007 at 05:47:29PM +0100, Mark Fortescue wrote:

> 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>
> ---

>  	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 */

> @@ -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;
> +			}
>  		}

It seems that you say that what was a single byte earlier is a __be16 now.
That is nice and well, but your code only works in the new case,
that is, may break all systems that work today.
What about testing vtoc.sanity, and if this has the right value do
the new things, and otherwise the old things?

Andries
-
To unsubscribe from this list: send the line "unsubscribe sparclinux" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[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