2N/A * The contents of this file are subject to the terms of the 2N/A * Common Development and Distribution License (the "License"). 2N/A * You may not use this file except in compliance with the License. 2N/A * See the License for the specific language governing permissions 2N/A * and limitations under the License. 2N/A * When distributing Covered Code, include this CDDL HEADER in each 2N/A * If applicable, add the following below this CDDL HEADER, with the 2N/A * fields enclosed by brackets "[]" replaced with your own identifying 2N/A * information: Portions Copyright [yyyy] [name of copyright owner] 2N/A * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved. 2N/A { 0 },
/* STAND is never used */ 2N/A { 0 },
/* is never used (was used by cachefs) */ 2N/A * Default vtoc information for non-SVr4 partitions 2N/A#
endif /* defined(i386) */ 2N/A#
endif /* defined(_SUNOS_VTOC_16) */ 2N/Aextern unsigned int efi_crc32(
const unsigned char *,
unsigned int);
2N/A * the number of blocks the EFI label takes up (round up to nearest 2N/A/* number of partitions -- limited by what we can malloc */ 2N/A "couldn't read disk information\n");
2N/A "the maximum number of partitions supported is %lu\n",
2N/A * add one block here for the PMBR; on disks with a 512 byte 2N/A * block size and 128 or fewer partitions, efi_first_u_lba 2N/A * should work out to "34" 2N/A * Read EFI - return partition number upon success. 2N/A /* figure out the number of entries that would fit into 16K */ 2N/A "read of EFI table failed, rval=%d\n",
rval);
2N/A "Bad EFI signature: 0x%llx != 0x%llx\n",
2N/A * check CRC of the header; the size of the header should 2N/A * never be larger than one block 2N/A "Bad EFI CRC: 0x%x != 0x%x\n",
2N/A * get the partition number for this file descriptor. 2N/A * The controller and drive name "vdc" (virtual disk client) 2N/A * indicates a LDoms virtual disk. 2N/A /* get the LBA size */ 2N/A "assuming LBA 512 bytes %d\n",
2N/A "efi_read: assuming LBA 512 bytes\n");
2N/A * Read the EFI GPT to figure out how many partitions we need 2N/A /* pad to physical sector size */ 2N/A * No valid label here; try the alternate. Note that here 2N/A * we just read GPT header and save it into dk_ioc.data, 2N/A * Later, we will read GUID partition entry array if we 2N/A * can get valid GPT header. 2N/A * This is a workaround for legacy systems. In the past, the 2N/A * last sector of SCSI disk was invisible on x86 platform. At 2N/A * that time, backup label was saved on the next to the last 2N/A * sector. It is possible for users to move a disk from previous 2N/A * solaris system to present system. Here, we attempt to search 2N/A * legacy backup EFI label first. 2N/A * we didn't find legacy backup EFI label, try to 2N/A * search backup EFI label in the last block. 2N/A "efi_read: primary label corrupt; " 2N/A "using EFI backup label located on" 2N/A " the last block\n");
2N/A " corrupt; using legacy EFI backup label " 2N/A " located on the next to last block\n");
2N/A * Partition tables are between backup GPT header 2N/A * table and ParitionEntryLBA (the starting LBA of 2N/A * the GUID partition entries array). Now that we 2N/A * already got valid GPT header and saved it in 2N/A * dk_ioc.dki_data, we try to get GUID partition 2N/A * read GUID partition entry array 2N/A * When the device is a LDoms virtual disk, the DKIOCGETEFI 2N/A * ioctl can fail with EINVAL if the virtual disk backend 2N/A * is a ZFS volume serviced by a domain running an old version 2N/A * of Solaris. This is because the DKIOCGETEFI ioctl was 2N/A * initially incorrectly implemented for a ZFS volume and it 2N/A * expected the GPT and GPE to be retrieved with a single ioctl. 2N/A * So we try to read the GPT and the GPE using that old style 2N/A /* LINTED -- always longlong aligned */ 2N/A * Assemble this into a "dk_gpt" struct for easier 2N/A * digestibility by applications. 2N/A * If the array the user passed in is too small, set the length 2N/A * to what it needs to be and return 2N/A "Found a partition " 2N/A "with unknown uuid," 2N/A "set its p_tag to %d.\n",
2N/A/* generate a unique 32-bit signature */ 2N/A/* writes a "protective" MBR */ 2N/A * Preserve any boot code and disk signature if the first block is 2N/A /* LINTED -- always longlong aligned */ 2N/A /* bootable or not */ 2N/A /* beginning CHS; 0xffffff if not representable */ 2N/A /* ending CHS; 0xffffff if not representable */ 2N/A /* starting LBA: 1 (little endian format) by EFI definition */ 2N/A /* ending LBA: last block on the disk (little endian format) */ 2N/A /* LINTED -- always longlong aligned */ 2N/A/* make sure the user specified something reasonable */ 2N/A /* Sanity-check the input */ 2N/A /* if the p_tag is V_UNKNOWN, we get it from p_guid */ 2N/A /* It can't be unassigned and have an actual size */ 2N/A "partition %d is \"unassigned\" " 2N/A "but has a size of %llu", i,
2N/A "Mismatch between unassigned tag " 2N/A " and non-null uuid at partition " 2N/A "defined at index %d.\n Only " 2N/A "partitions 0 to 6 are directly accessible " 2N/A "through device minor nodes\n", i);
2N/A "duplicate reserved partition at " 2N/A "reserved partition (at %d) must be either " 2N/A "at partition 8 or partition 0 to 6\n", i);
2N/A "Partition %d starts at %llu. ",
2N/A "It must be between %llu and %llu.\n",
2N/A "Partition %d ends at %llu. ",
2N/A "It must be between %llu and %llu.\n",
2N/A "Partition %d overlaps " 2N/A "partition %d.", i, j);
2N/A /* just a warning for now */ 2N/A "no reserved partition found\n");
2N/A * add all the unallocated space to the current label 2N/A /* find the reserved partition */ 2N/A "efi_use_whole_disk:reserved partition " 2N/A * find the last physically non-zero partition other than 2N/A * the reserved partition 2N/A * If alter_lba is 1, we are using the backup label. 2N/A * Since we can locate the backup label by disk capacity, 2N/A * there must be no unallocated space. 2N/A "efi_use_whole_disk: requested space not found\n");
2N/A * If the reserved partition is right before the backup label, add the 2N/A * new space to the last physically non-zero area before the reserved 2N/A * Move the reserved partition. There is currently no data in 2N/A * here except fabricated devids (which get generated via 2N/A * efi_write()). So there is no need to copy data. 2N/A * Otherwise, add the new space to the last physically non-zero 2N/A * area before the backup label. 2N/A "efi_use_whole_disk:fail to write label, rval=%d\n",
2N/A * write EFI label and backup label 2N/A /* check if we are dealing wih a metadevice */ 2N/A * not valid; if it's a metadevice just pass it down 2N/A * because SVM will do its own checking 2N/A "label is out of the entries allocated on disk\n");
2N/A "The value of efi_reserved[12] " 2N/A "in the label must be set to zero\n");
2N/A * the number of blocks occupied by GUID partition entry array 2N/A * Backup GPT header is located on the block after GUID 2N/A * partition entry array. Here, we calculate the address 2N/A * for backup GPT header. 2N/A /* stuff user's input into EFI struct */ 2N/A /* LINTED -- always longlong aligned */ 2N/A /* use uuid directly */ 2N/A * If we didn't have a matching uuid match, 2N/A * Don't write a label with unknown uuid. 2N/A "Unknown uuid for p_tag %d\n",
2N/A /* if it's a metadevice we're done */ 2N/A /* write backup partition array */ 2N/A * we wrote the primary label okay, so don't fail 2N/A "write of backup partitions to block %llu " 2N/A "failed, errno %d\n",
2N/A * now swap MyLBA and AlternateLBA fields and write backup 2N/A * partition table header 2N/A "write of backup header to block %llu failed, " 2N/A /* write the PMBR */ 2N/A * Input: File descriptor 2N/A * Output: 1 if disk has an EFI label, or > 2TB with no VTOC or legacy MBR. 2N/A * make sure no partitions overlap 2N/A /* It can't be unassigned and have an actual size */ 2N/A "partition %d is \"unassigned\" but has a size " 2N/A "found duplicate reserved partition at " 2N/A "Warning: reserved partition size must " 2N/A "Partition %d starts at %llu\n",
2N/A "It must be between %llu and %llu.\n",
2N/A "Partition %d ends at %llu\n",
2N/A "It must be between %llu and %llu.\n",
2N/A "label error: EFI Labels do not " 2N/A "support overlapping partitions\n");
2N/A "Partition %d overlaps partition " 2N/A /* make sure there is a reserved partition */ 2N/A "no reserved partition found\n");
2N/A * We need to get information necessary to construct a *new* efi 2N/A * Now build the default partition table 2N/A * Make constants first 2N/A * and variable partitions later 2N/A /* root partition - s0 128 MB */ 2N/A /* partition - s1 128 MB */ 2N/A /* partition -s2 is NOT the Backup disk */ 2N/A /* partition -s6 /usr partition - HOG */ 2N/A /* efi reserved partition - s9 16K */