diff options
author | yl194034 <none@none> | 2007-05-23 22:18:37 -0700 |
---|---|---|
committer | yl194034 <none@none> | 2007-05-23 22:18:37 -0700 |
commit | 1cce8a3fd4de339002c756b920bbddde497b9f78 (patch) | |
tree | 145628cf195ea199742d95f5b35def555dc91588 | |
parent | 5dbcb2a2ded752a6731e3db12a239d1380080da3 (diff) | |
download | illumos-joyent-1cce8a3fd4de339002c756b920bbddde497b9f78.tar.gz |
6466433 Default EFI slice table leaves one sector unused.
6474622 auto configure to a EFI labeled lun should generate a whole hog partition table
6537609 validate64 function reads past the end of efi->parts
-rw-r--r-- | usr/src/cmd/fmthard/fmthard.c | 4 | ||||
-rw-r--r-- | usr/src/cmd/format/auto_sense.c | 48 | ||||
-rw-r--r-- | usr/src/cmd/format/label.c | 6 |
3 files changed, 27 insertions, 31 deletions
diff --git a/usr/src/cmd/fmthard/fmthard.c b/usr/src/cmd/fmthard/fmthard.c index 155199bed2..4d24e712dd 100644 --- a/usr/src/cmd/fmthard/fmthard.c +++ b/usr/src/cmd/fmthard/fmthard.c @@ -31,7 +31,7 @@ #pragma ident "%Z%%M% %I% %E% SMI" /* - * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -824,7 +824,7 @@ fmthard: Partition %d specified as %lld sectors starting at %lld\n\ if (efi->efi_parts[i].p_tag != V_BACKUP && efi->efi_parts[i].p_size != fullsz) { - for (j = 0; j < V_NUMPAR; j++) { + for (j = 0; j < efi->efi_nparts; j++) { if (efi->efi_parts[j].p_size == fullsz) continue; isize = efi->efi_parts[i].p_size; diff --git a/usr/src/cmd/format/auto_sense.c b/usr/src/cmd/format/auto_sense.c index cd22fcc78b..22e841a7b2 100644 --- a/usr/src/cmd/format/auto_sense.c +++ b/usr/src/cmd/format/auto_sense.c @@ -19,7 +19,7 @@ * CDDL HEADER END */ /* - * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -272,37 +272,33 @@ auto_efi_sense(int fd, struct efi_info *label) label->e_parts = vtoc; - for (i = 0; i < min(vtoc->efi_nparts, V_NUMPAR); i++) { - vtoc->efi_parts[i].p_tag = default_vtoc_map[i].p_tag; - vtoc->efi_parts[i].p_flag = default_vtoc_map[i].p_flag; + /* + * Create a whole hog EFI partition table: + * S0 takes the whole disk except the primary EFI label, + * backup EFI label, and the reserved partition. + */ + vtoc->efi_parts[0].p_tag = V_USR; + vtoc->efi_parts[0].p_start = vtoc->efi_first_u_lba; + vtoc->efi_parts[0].p_size = vtoc->efi_last_u_lba - vtoc->efi_first_u_lba + - EFI_MIN_RESV_SIZE + 1; + + /* + * S1-S6 are unassigned slices. + */ + for (i = 1; i < vtoc->efi_nparts - 2; i ++) { + vtoc->efi_parts[i].p_tag = V_UNASSIGNED; vtoc->efi_parts[i].p_start = 0; vtoc->efi_parts[i].p_size = 0; } + /* - * Make constants first - * and variable partitions later + * The reserved slice */ + vtoc->efi_parts[vtoc->efi_nparts - 1].p_tag = V_RESERVED; + vtoc->efi_parts[vtoc->efi_nparts - 1].p_start = + vtoc->efi_last_u_lba - EFI_MIN_RESV_SIZE + 1; + vtoc->efi_parts[vtoc->efi_nparts - 1].p_size = EFI_MIN_RESV_SIZE; - /* root partition - s0 128 MB */ - vtoc->efi_parts[0].p_start = 34; - vtoc->efi_parts[0].p_size = 262144; - - /* partition - s1 128 MB */ - vtoc->efi_parts[1].p_start = 262178; - vtoc->efi_parts[1].p_size = 262144; - - /* partition -s2 is NOT the Backup disk */ - vtoc->efi_parts[2].p_tag = V_UNASSIGNED; - - /* partition -s6 /usr partition - HOG */ - vtoc->efi_parts[6].p_start = 524322; - vtoc->efi_parts[6].p_size = vtoc->efi_last_u_lba - 524322 - - (1024 * 16); - - /* efi reserved partition - s9 16K */ - vtoc->efi_parts[8].p_start = vtoc->efi_last_u_lba - (1024 * 16); - vtoc->efi_parts[8].p_size = (1024 * 16); - vtoc->efi_parts[8].p_tag = V_RESERVED; /* * Now stick all of it into the disk_type struct */ diff --git a/usr/src/cmd/format/label.c b/usr/src/cmd/format/label.c index 6f7e887f39..56c4aa1ce4 100644 --- a/usr/src/cmd/format/label.c +++ b/usr/src/cmd/format/label.c @@ -19,7 +19,7 @@ * CDDL HEADER END */ /* - * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -234,7 +234,7 @@ SMI_vtoc_to_EFI(int fd, struct dk_gpt **new_vtoc) efi->efi_parts[0].p_tag = V_USR; efi->efi_parts[0].p_start = efi->efi_first_u_lba; efi->efi_parts[0].p_size = efi->efi_last_u_lba - efi->efi_first_u_lba - - EFI_MIN_RESV_SIZE; + - EFI_MIN_RESV_SIZE + 1; /* * s1-s6 are unassigned slices @@ -250,7 +250,7 @@ SMI_vtoc_to_EFI(int fd, struct dk_gpt **new_vtoc) */ efi->efi_parts[efi->efi_nparts - 1].p_tag = V_RESERVED; efi->efi_parts[efi->efi_nparts - 1].p_start = - efi->efi_last_u_lba - EFI_MIN_RESV_SIZE; + efi->efi_last_u_lba - EFI_MIN_RESV_SIZE + 1; efi->efi_parts[efi->efi_nparts - 1].p_size = EFI_MIN_RESV_SIZE; return (0); |