4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
24 * Copyright 2012 Nexenta Systems, Inc. All rights reserved.
32 #include <uuid/uuid.h>
35 #include <sys/types.h>
39 #include <sys/param.h>
40 #include <sys/dktp/fdisk.h>
41 #include <sys/efi_partition.h>
42 #include <sys/byteorder.h>
43 #if defined(__linux__)
47 static struct uuid_to_ptag
{
49 } conversion_array
[] = {
56 { EFI_UNUSED
}, /* STAND is never used */
60 { EFI_UNUSED
}, /* CACHE (cachefs) is never used */
77 { EFI_FREEBSD_VINUM
},
87 { EFI_MSFT_STORAGESPACES
},
95 { EFI_FREEBSD_DISKLABEL
},
97 { EFI_AAPL_RAIDOFFLINE
},
100 { EFI_AAPL_TVRECOVERY
},
101 { EFI_AAPL_CORESTORAGE
},
107 { EFI_NETBSD_CRYPT
},
112 { EFI_MIDNIGHTBSD_BOOT
},
113 { EFI_MIDNIGHTBSD_DATA
},
114 { EFI_MIDNIGHTBSD_SWAP
},
115 { EFI_MIDNIGHTBSD_UFS
},
116 { EFI_MIDNIGHTBSD_VINUM
},
117 { EFI_MIDNIGHTBSD_ZFS
},
118 { EFI_CEPH_JOURNAL
},
119 { EFI_CEPH_DMCRYPTJOURNAL
},
121 { EFI_CEPH_DMCRYPTOSD
},
123 { EFI_CEPH_DMCRYPTCREATE
},
124 { EFI_OPENBSD_DISKLABEL
},
131 { EFI_RHT_ROOTAMD64
},
133 { EFI_RHT_ROOTARM64
},
134 { EFI_ACRONIS_SECUREZONE
},
137 { EFI_IBM_PPRPBOOT
},
138 { EFI_FREEDESKTOP_BOOT
}
142 * Default vtoc information for non-SVr4 partitions
144 struct dk_map2 default_vtoc_map
[NDKMAP
] = {
145 { V_ROOT
, 0 }, /* a - 0 */
146 { V_SWAP
, V_UNMNT
}, /* b - 1 */
147 { V_BACKUP
, V_UNMNT
}, /* c - 2 */
148 { V_UNASSIGNED
, 0 }, /* d - 3 */
149 { V_UNASSIGNED
, 0 }, /* e - 4 */
150 { V_UNASSIGNED
, 0 }, /* f - 5 */
151 { V_USR
, 0 }, /* g - 6 */
152 { V_UNASSIGNED
, 0 }, /* h - 7 */
154 #if defined(_SUNOS_VTOC_16)
156 #if defined(i386) || defined(__amd64) || defined(__arm) || \
157 defined(__powerpc) || defined(__sparc) || defined(__s390__) || \
159 { V_BOOT
, V_UNMNT
}, /* i - 8 */
160 { V_ALTSCTR
, 0 }, /* j - 9 */
163 #error No VTOC format defined.
164 #endif /* defined(i386) */
166 { V_UNASSIGNED
, 0 }, /* k - 10 */
167 { V_UNASSIGNED
, 0 }, /* l - 11 */
168 { V_UNASSIGNED
, 0 }, /* m - 12 */
169 { V_UNASSIGNED
, 0 }, /* n - 13 */
170 { V_UNASSIGNED
, 0 }, /* o - 14 */
171 { V_UNASSIGNED
, 0 }, /* p - 15 */
172 #endif /* defined(_SUNOS_VTOC_16) */
177 static int efi_read(int, struct dk_gpt
*);
180 * Return a 32-bit CRC of the contents of the buffer. Pre-and-post
181 * one's conditioning will be handled by crc32() internally.
184 efi_crc32(const unsigned char *buf
, unsigned int size
)
186 uint32_t crc
= crc32(0, Z_NULL
, 0);
188 crc
= crc32(crc
, buf
, size
);
194 read_disk_info(int fd
, diskaddr_t
*capacity
, uint_t
*lbsize
)
197 unsigned long long capacity_size
;
199 if (ioctl(fd
, BLKSSZGET
, §or_size
) < 0)
202 if (ioctl(fd
, BLKGETSIZE64
, &capacity_size
) < 0)
205 *lbsize
= (uint_t
)sector_size
;
206 *capacity
= (diskaddr_t
)(capacity_size
/ sector_size
);
212 efi_get_info(int fd
, struct dk_cinfo
*dki_info
)
214 #if defined(__linux__)
219 memset(dki_info
, 0, sizeof (*dki_info
));
221 path
= calloc(PATH_MAX
, 1);
226 * The simplest way to get the partition number under linux is
227 * to parse it out of the /dev/<disk><parition> block device name.
228 * The kernel creates this using the partition number when it
229 * populates /dev/ so it may be trusted. The tricky bit here is
230 * that the naming convention is based on the block device type.
231 * So we need to take this in to account when parsing out the
232 * partition information. Another issue is that the libefi API
233 * API only provides the open fd and not the file path. To handle
234 * this realpath(3) is used to resolve the block device name from
235 * /proc/self/fd/<fd>. Aside from the partition number we collect
236 * some additional device info.
238 (void) sprintf(path
, "/proc/self/fd/%d", fd
);
239 dev_path
= realpath(path
, NULL
);
242 if (dev_path
== NULL
)
245 if ((strncmp(dev_path
, "/dev/sd", 7) == 0)) {
246 strcpy(dki_info
->dki_cname
, "sd");
247 dki_info
->dki_ctype
= DKC_SCSI_CCS
;
248 rval
= sscanf(dev_path
, "/dev/%[a-zA-Z]%hu",
250 &dki_info
->dki_partition
);
251 } else if ((strncmp(dev_path
, "/dev/hd", 7) == 0)) {
252 strcpy(dki_info
->dki_cname
, "hd");
253 dki_info
->dki_ctype
= DKC_DIRECT
;
254 rval
= sscanf(dev_path
, "/dev/%[a-zA-Z]%hu",
256 &dki_info
->dki_partition
);
257 } else if ((strncmp(dev_path
, "/dev/md", 7) == 0)) {
258 strcpy(dki_info
->dki_cname
, "pseudo");
259 dki_info
->dki_ctype
= DKC_MD
;
260 strcpy(dki_info
->dki_dname
, "md");
261 rval
= sscanf(dev_path
, "/dev/md%[0-9]p%hu",
262 dki_info
->dki_dname
+ 2,
263 &dki_info
->dki_partition
);
264 } else if ((strncmp(dev_path
, "/dev/vd", 7) == 0)) {
265 strcpy(dki_info
->dki_cname
, "vd");
266 dki_info
->dki_ctype
= DKC_MD
;
267 rval
= sscanf(dev_path
, "/dev/%[a-zA-Z]%hu",
269 &dki_info
->dki_partition
);
270 } else if ((strncmp(dev_path
, "/dev/xvd", 8) == 0)) {
271 strcpy(dki_info
->dki_cname
, "xvd");
272 dki_info
->dki_ctype
= DKC_MD
;
273 rval
= sscanf(dev_path
, "/dev/%[a-zA-Z]%hu",
275 &dki_info
->dki_partition
);
276 } else if ((strncmp(dev_path
, "/dev/zd", 7) == 0)) {
277 strcpy(dki_info
->dki_cname
, "zd");
278 dki_info
->dki_ctype
= DKC_MD
;
279 rval
= sscanf(dev_path
, "/dev/%[a-zA-Z]%hu",
281 &dki_info
->dki_partition
);
282 } else if ((strncmp(dev_path
, "/dev/dm-", 8) == 0)) {
283 strcpy(dki_info
->dki_cname
, "pseudo");
284 dki_info
->dki_ctype
= DKC_VBD
;
285 strcpy(dki_info
->dki_dname
, "dm-");
286 rval
= sscanf(dev_path
, "/dev/dm-%[0-9]p%hu",
287 dki_info
->dki_dname
+ 3,
288 &dki_info
->dki_partition
);
289 } else if ((strncmp(dev_path
, "/dev/ram", 8) == 0)) {
290 strcpy(dki_info
->dki_cname
, "pseudo");
291 dki_info
->dki_ctype
= DKC_PCMCIA_MEM
;
292 strcpy(dki_info
->dki_dname
, "ram");
293 rval
= sscanf(dev_path
, "/dev/ram%[0-9]p%hu",
294 dki_info
->dki_dname
+ 3,
295 &dki_info
->dki_partition
);
296 } else if ((strncmp(dev_path
, "/dev/loop", 9) == 0)) {
297 strcpy(dki_info
->dki_cname
, "pseudo");
298 dki_info
->dki_ctype
= DKC_VBD
;
299 strcpy(dki_info
->dki_dname
, "loop");
300 rval
= sscanf(dev_path
, "/dev/loop%[0-9]p%hu",
301 dki_info
->dki_dname
+ 4,
302 &dki_info
->dki_partition
);
303 } else if ((strncmp(dev_path
, "/dev/nvme", 9) == 0)) {
304 strcpy(dki_info
->dki_cname
, "nvme");
305 dki_info
->dki_ctype
= DKC_SCSI_CCS
;
306 strcpy(dki_info
->dki_dname
, "nvme");
307 (void) sscanf(dev_path
, "/dev/nvme%[0-9]",
308 dki_info
->dki_dname
+ 4);
309 size_t controller_length
= strlen(
310 dki_info
->dki_dname
);
311 strcpy(dki_info
->dki_dname
+ controller_length
,
313 rval
= sscanf(dev_path
,
314 "/dev/nvme%*[0-9]n%[0-9]p%hu",
315 dki_info
->dki_dname
+ controller_length
+ 1,
316 &dki_info
->dki_partition
);
318 strcpy(dki_info
->dki_dname
, "unknown");
319 strcpy(dki_info
->dki_cname
, "unknown");
320 dki_info
->dki_ctype
= DKC_UNKNOWN
;
328 dki_info
->dki_partition
= 0;
333 if (ioctl(fd
, DKIOCINFO
, (caddr_t
)dki_info
) == -1)
339 (void) fprintf(stderr
, "DKIOCINFO errno 0x%x\n", errno
);
352 * the number of blocks the EFI label takes up (round up to nearest
355 #define NBLOCKS(p, l) (1 + ((((p) * (int)sizeof (efi_gpe_t)) + \
357 /* number of partitions -- limited by what we can malloc */
358 #define MAX_PARTS ((4294967295UL - sizeof (struct dk_gpt)) / \
359 sizeof (struct dk_part))
362 efi_alloc_and_init(int fd
, uint32_t nparts
, struct dk_gpt
**vtoc
)
364 diskaddr_t capacity
= 0;
370 struct dk_cinfo dki_info
;
372 if (read_disk_info(fd
, &capacity
, &lbsize
) != 0)
375 #if defined(__linux__)
376 if (efi_get_info(fd
, &dki_info
) != 0)
379 if (dki_info
.dki_partition
!= 0)
382 if ((dki_info
.dki_ctype
== DKC_PCMCIA_MEM
) ||
383 (dki_info
.dki_ctype
== DKC_VBD
) ||
384 (dki_info
.dki_ctype
== DKC_UNKNOWN
))
388 nblocks
= NBLOCKS(nparts
, lbsize
);
389 if ((nblocks
* lbsize
) < EFI_MIN_ARRAY_SIZE
+ lbsize
) {
390 /* 16K plus one block for the GPT */
391 nblocks
= EFI_MIN_ARRAY_SIZE
/ lbsize
+ 1;
394 if (nparts
> MAX_PARTS
) {
396 (void) fprintf(stderr
,
397 "the maximum number of partitions supported is %lu\n",
403 length
= sizeof (struct dk_gpt
) +
404 sizeof (struct dk_part
) * (nparts
- 1);
406 if ((*vtoc
= calloc(length
, 1)) == NULL
)
411 vptr
->efi_version
= EFI_VERSION_CURRENT
;
412 vptr
->efi_lbasize
= lbsize
;
413 vptr
->efi_nparts
= nparts
;
415 * add one block here for the PMBR; on disks with a 512 byte
416 * block size and 128 or fewer partitions, efi_first_u_lba
417 * should work out to "34"
419 vptr
->efi_first_u_lba
= nblocks
+ 1;
420 vptr
->efi_last_lba
= capacity
- 1;
421 vptr
->efi_altern_lba
= capacity
-1;
422 vptr
->efi_last_u_lba
= vptr
->efi_last_lba
- nblocks
;
424 (void) uuid_generate((uchar_t
*)&uuid
);
425 UUID_LE_CONVERT(vptr
->efi_disk_uguid
, uuid
);
430 * Read EFI - return partition number upon success.
433 efi_alloc_and_read(int fd
, struct dk_gpt
**vtoc
)
439 /* figure out the number of entries that would fit into 16K */
440 nparts
= EFI_MIN_ARRAY_SIZE
/ sizeof (efi_gpe_t
);
441 length
= (int) sizeof (struct dk_gpt
) +
442 (int) sizeof (struct dk_part
) * (nparts
- 1);
443 if ((*vtoc
= calloc(length
, 1)) == NULL
)
446 (*vtoc
)->efi_nparts
= nparts
;
447 rval
= efi_read(fd
, *vtoc
);
449 if ((rval
== VT_EINVAL
) && (*vtoc
)->efi_nparts
> nparts
) {
451 length
= (int) sizeof (struct dk_gpt
) +
452 (int) sizeof (struct dk_part
) *
453 ((*vtoc
)->efi_nparts
- 1);
454 nparts
= (*vtoc
)->efi_nparts
;
455 if ((tmp
= realloc(*vtoc
, length
)) == NULL
) {
461 rval
= efi_read(fd
, *vtoc
);
467 (void) fprintf(stderr
,
468 "read of EFI table failed, rval=%d\n", rval
);
478 efi_ioctl(int fd
, int cmd
, dk_efi_t
*dk_ioc
)
480 void *data
= dk_ioc
->dki_data
;
482 #if defined(__linux__)
487 * When the IO is not being performed in kernel as an ioctl we need
488 * to know the sector size so we can seek to the proper byte offset.
490 if (read_disk_info(fd
, &capacity
, &lbsize
) == -1) {
492 fprintf(stderr
, "unable to read disk info: %d", errno
);
502 (void) fprintf(stderr
, "DKIOCGETEFI assuming "
503 "LBA %d bytes\n", DEV_BSIZE
);
508 error
= lseek(fd
, dk_ioc
->dki_lba
* lbsize
, SEEK_SET
);
511 (void) fprintf(stderr
, "DKIOCGETEFI lseek "
512 "error: %d\n", errno
);
516 error
= read(fd
, data
, dk_ioc
->dki_length
);
519 (void) fprintf(stderr
, "DKIOCGETEFI read "
520 "error: %d\n", errno
);
524 if (error
!= dk_ioc
->dki_length
) {
526 (void) fprintf(stderr
, "DKIOCGETEFI short "
527 "read of %d bytes\n", error
);
537 (void) fprintf(stderr
, "DKIOCSETEFI unknown "
543 error
= lseek(fd
, dk_ioc
->dki_lba
* lbsize
, SEEK_SET
);
546 (void) fprintf(stderr
, "DKIOCSETEFI lseek "
547 "error: %d\n", errno
);
551 error
= write(fd
, data
, dk_ioc
->dki_length
);
554 (void) fprintf(stderr
, "DKIOCSETEFI write "
555 "error: %d\n", errno
);
559 if (error
!= dk_ioc
->dki_length
) {
561 (void) fprintf(stderr
, "DKIOCSETEFI short "
562 "write of %d bytes\n", error
);
567 /* Sync the new EFI table to disk */
572 /* Ensure any local disk cache is also flushed */
573 if (ioctl(fd
, BLKFLSBUF
, 0) == -1)
581 (void) fprintf(stderr
, "unsupported ioctl()\n");
587 dk_ioc
->dki_data_64
= (uint64_t)(uintptr_t)data
;
588 error
= ioctl(fd
, cmd
, (void *)dk_ioc
);
589 dk_ioc
->dki_data
= data
;
597 #if defined(__linux__)
601 /* Notify the kernel a devices partition table has been updated */
602 while ((error
= ioctl(fd
, BLKRRPART
)) != 0) {
603 if ((--retry
== 0) || (errno
!= EBUSY
)) {
604 (void) fprintf(stderr
, "the kernel failed to rescan "
605 "the partition table: %d\n", errno
);
616 check_label(int fd
, dk_efi_t
*dk_ioc
)
621 if (efi_ioctl(fd
, DKIOCGETEFI
, dk_ioc
) == -1) {
629 efi
= dk_ioc
->dki_data
;
630 if (efi
->efi_gpt_Signature
!= LE_64(EFI_SIGNATURE
)) {
632 (void) fprintf(stderr
,
633 "Bad EFI signature: 0x%llx != 0x%llx\n",
634 (long long)efi
->efi_gpt_Signature
,
635 (long long)LE_64(EFI_SIGNATURE
));
640 * check CRC of the header; the size of the header should
641 * never be larger than one block
643 crc
= efi
->efi_gpt_HeaderCRC32
;
644 efi
->efi_gpt_HeaderCRC32
= 0;
645 len_t headerSize
= (len_t
)LE_32(efi
->efi_gpt_HeaderSize
);
647 if (headerSize
< EFI_MIN_LABEL_SIZE
|| headerSize
> EFI_LABEL_SIZE
) {
649 (void) fprintf(stderr
,
650 "Invalid EFI HeaderSize %llu. Assuming %d.\n",
651 headerSize
, EFI_MIN_LABEL_SIZE
);
654 if ((headerSize
> dk_ioc
->dki_length
) ||
655 crc
!= LE_32(efi_crc32((unsigned char *)efi
, headerSize
))) {
657 (void) fprintf(stderr
,
658 "Bad EFI CRC: 0x%x != 0x%x\n",
659 crc
, LE_32(efi_crc32((unsigned char *)efi
,
668 efi_read(int fd
, struct dk_gpt
*vtoc
)
675 diskaddr_t capacity
= 0;
677 struct dk_minfo disk_info
;
680 efi_gpe_t
*efi_parts
;
681 struct dk_cinfo dki_info
;
682 uint32_t user_length
;
683 boolean_t legacy_label
= B_FALSE
;
686 * get the partition number for this file descriptor.
688 if ((rval
= efi_get_info(fd
, &dki_info
)) != 0)
691 if ((strncmp(dki_info
.dki_cname
, "pseudo", 7) == 0) &&
692 (strncmp(dki_info
.dki_dname
, "md", 3) == 0)) {
694 } else if ((strncmp(dki_info
.dki_cname
, "vdc", 4) == 0) &&
695 (strncmp(dki_info
.dki_dname
, "vdc", 4) == 0)) {
697 * The controller and drive name "vdc" (virtual disk client)
698 * indicates a LDoms virtual disk.
703 /* get the LBA size */
704 if (read_disk_info(fd
, &capacity
, &lbsize
) == -1) {
706 (void) fprintf(stderr
,
707 "unable to read disk info: %d",
713 disk_info
.dki_lbsize
= lbsize
;
714 disk_info
.dki_capacity
= capacity
;
716 if (disk_info
.dki_lbsize
== 0) {
718 (void) fprintf(stderr
,
719 "efi_read: assuming LBA 512 bytes\n");
721 disk_info
.dki_lbsize
= DEV_BSIZE
;
724 * Read the EFI GPT to figure out how many partitions we need
728 if (NBLOCKS(vtoc
->efi_nparts
, disk_info
.dki_lbsize
) < 34) {
729 label_len
= EFI_MIN_ARRAY_SIZE
+ disk_info
.dki_lbsize
;
731 label_len
= vtoc
->efi_nparts
* (int) sizeof (efi_gpe_t
) +
732 disk_info
.dki_lbsize
;
733 if (label_len
% disk_info
.dki_lbsize
) {
734 /* pad to physical sector size */
735 label_len
+= disk_info
.dki_lbsize
;
736 label_len
&= ~(disk_info
.dki_lbsize
- 1);
740 if (posix_memalign((void **)&dk_ioc
.dki_data
,
741 disk_info
.dki_lbsize
, label_len
))
744 memset(dk_ioc
.dki_data
, 0, label_len
);
745 dk_ioc
.dki_length
= disk_info
.dki_lbsize
;
746 user_length
= vtoc
->efi_nparts
;
747 efi
= dk_ioc
.dki_data
;
749 dk_ioc
.dki_length
= label_len
;
750 if (efi_ioctl(fd
, DKIOCGETEFI
, &dk_ioc
) == -1) {
758 } else if ((rval
= check_label(fd
, &dk_ioc
)) == VT_EINVAL
) {
760 * No valid label here; try the alternate. Note that here
761 * we just read GPT header and save it into dk_ioc.data,
762 * Later, we will read GUID partition entry array if we
763 * can get valid GPT header.
767 * This is a workaround for legacy systems. In the past, the
768 * last sector of SCSI disk was invisible on x86 platform. At
769 * that time, backup label was saved on the next to the last
770 * sector. It is possible for users to move a disk from previous
771 * solaris system to present system. Here, we attempt to search
772 * legacy backup EFI label first.
774 dk_ioc
.dki_lba
= disk_info
.dki_capacity
- 2;
775 dk_ioc
.dki_length
= disk_info
.dki_lbsize
;
776 rval
= check_label(fd
, &dk_ioc
);
777 if (rval
== VT_EINVAL
) {
779 * we didn't find legacy backup EFI label, try to
780 * search backup EFI label in the last block.
782 dk_ioc
.dki_lba
= disk_info
.dki_capacity
- 1;
783 dk_ioc
.dki_length
= disk_info
.dki_lbsize
;
784 rval
= check_label(fd
, &dk_ioc
);
786 legacy_label
= B_TRUE
;
788 (void) fprintf(stderr
,
789 "efi_read: primary label corrupt; "
790 "using EFI backup label located on"
791 " the last block\n");
794 if ((efi_debug
) && (rval
== 0))
795 (void) fprintf(stderr
, "efi_read: primary label"
796 " corrupt; using legacy EFI backup label "
797 " located on the next to last block\n");
801 dk_ioc
.dki_lba
= LE_64(efi
->efi_gpt_PartitionEntryLBA
);
802 vtoc
->efi_flags
|= EFI_GPT_PRIMARY_CORRUPT
;
804 LE_32(efi
->efi_gpt_NumberOfPartitionEntries
);
806 * Partition tables are between backup GPT header
807 * table and ParitionEntryLBA (the starting LBA of
808 * the GUID partition entries array). Now that we
809 * already got valid GPT header and saved it in
810 * dk_ioc.dki_data, we try to get GUID partition
814 dk_ioc
.dki_data
= (efi_gpt_t
*)((char *)dk_ioc
.dki_data
815 + disk_info
.dki_lbsize
);
817 dk_ioc
.dki_length
= disk_info
.dki_capacity
- 1 -
820 dk_ioc
.dki_length
= disk_info
.dki_capacity
- 2 -
822 dk_ioc
.dki_length
*= disk_info
.dki_lbsize
;
823 if (dk_ioc
.dki_length
>
824 ((len_t
)label_len
- sizeof (*dk_ioc
.dki_data
))) {
828 * read GUID partition entry array
830 rval
= efi_ioctl(fd
, DKIOCGETEFI
, &dk_ioc
);
834 } else if (rval
== 0) {
836 dk_ioc
.dki_lba
= LE_64(efi
->efi_gpt_PartitionEntryLBA
);
838 dk_ioc
.dki_data
= (efi_gpt_t
*)((char *)dk_ioc
.dki_data
839 + disk_info
.dki_lbsize
);
840 dk_ioc
.dki_length
= label_len
- disk_info
.dki_lbsize
;
841 rval
= efi_ioctl(fd
, DKIOCGETEFI
, &dk_ioc
);
843 } else if (vdc_flag
&& rval
== VT_ERROR
&& errno
== EINVAL
) {
845 * When the device is a LDoms virtual disk, the DKIOCGETEFI
846 * ioctl can fail with EINVAL if the virtual disk backend
847 * is a ZFS volume serviced by a domain running an old version
848 * of Solaris. This is because the DKIOCGETEFI ioctl was
849 * initially incorrectly implemented for a ZFS volume and it
850 * expected the GPT and GPE to be retrieved with a single ioctl.
851 * So we try to read the GPT and the GPE using that old style
855 dk_ioc
.dki_length
= label_len
;
856 rval
= check_label(fd
, &dk_ioc
);
864 /* LINTED -- always longlong aligned */
865 efi_parts
= (efi_gpe_t
*)(((char *)efi
) + disk_info
.dki_lbsize
);
868 * Assemble this into a "dk_gpt" struct for easier
869 * digestibility by applications.
871 vtoc
->efi_version
= LE_32(efi
->efi_gpt_Revision
);
872 vtoc
->efi_nparts
= LE_32(efi
->efi_gpt_NumberOfPartitionEntries
);
873 vtoc
->efi_part_size
= LE_32(efi
->efi_gpt_SizeOfPartitionEntry
);
874 vtoc
->efi_lbasize
= disk_info
.dki_lbsize
;
875 vtoc
->efi_last_lba
= disk_info
.dki_capacity
- 1;
876 vtoc
->efi_first_u_lba
= LE_64(efi
->efi_gpt_FirstUsableLBA
);
877 vtoc
->efi_last_u_lba
= LE_64(efi
->efi_gpt_LastUsableLBA
);
878 vtoc
->efi_altern_lba
= LE_64(efi
->efi_gpt_AlternateLBA
);
879 UUID_LE_CONVERT(vtoc
->efi_disk_uguid
, efi
->efi_gpt_DiskGUID
);
882 * If the array the user passed in is too small, set the length
883 * to what it needs to be and return
885 if (user_length
< vtoc
->efi_nparts
) {
889 for (i
= 0; i
< vtoc
->efi_nparts
; i
++) {
891 UUID_LE_CONVERT(vtoc
->efi_parts
[i
].p_guid
,
892 efi_parts
[i
].efi_gpe_PartitionTypeGUID
);
895 j
< sizeof (conversion_array
)
896 / sizeof (struct uuid_to_ptag
); j
++) {
898 if (bcmp(&vtoc
->efi_parts
[i
].p_guid
,
899 &conversion_array
[j
].uuid
,
900 sizeof (struct uuid
)) == 0) {
901 vtoc
->efi_parts
[i
].p_tag
= j
;
905 if (vtoc
->efi_parts
[i
].p_tag
== V_UNASSIGNED
)
907 vtoc
->efi_parts
[i
].p_flag
=
908 LE_16(efi_parts
[i
].efi_gpe_Attributes
.PartitionAttrs
);
909 vtoc
->efi_parts
[i
].p_start
=
910 LE_64(efi_parts
[i
].efi_gpe_StartingLBA
);
911 vtoc
->efi_parts
[i
].p_size
=
912 LE_64(efi_parts
[i
].efi_gpe_EndingLBA
) -
913 vtoc
->efi_parts
[i
].p_start
+ 1;
914 for (j
= 0; j
< EFI_PART_NAME_LEN
; j
++) {
915 vtoc
->efi_parts
[i
].p_name
[j
] =
917 efi_parts
[i
].efi_gpe_PartitionName
[j
]);
920 UUID_LE_CONVERT(vtoc
->efi_parts
[i
].p_uguid
,
921 efi_parts
[i
].efi_gpe_UniquePartitionGUID
);
925 return (dki_info
.dki_partition
);
928 /* writes a "protective" MBR */
930 write_pmbr(int fd
, struct dk_gpt
*vtoc
)
935 diskaddr_t size_in_lba
;
939 len
= (vtoc
->efi_lbasize
== 0) ? sizeof (mb
) : vtoc
->efi_lbasize
;
940 if (posix_memalign((void **)&buf
, len
, len
))
944 * Preserve any boot code and disk signature if the first block is
949 dk_ioc
.dki_length
= len
;
950 /* LINTED -- always longlong aligned */
951 dk_ioc
.dki_data
= (efi_gpt_t
*)buf
;
952 if (efi_ioctl(fd
, DKIOCGETEFI
, &dk_ioc
) == -1) {
953 (void) memcpy(&mb
, buf
, sizeof (mb
));
954 bzero(&mb
, sizeof (mb
));
955 mb
.signature
= LE_16(MBB_MAGIC
);
957 (void) memcpy(&mb
, buf
, sizeof (mb
));
958 if (mb
.signature
!= LE_16(MBB_MAGIC
)) {
959 bzero(&mb
, sizeof (mb
));
960 mb
.signature
= LE_16(MBB_MAGIC
);
964 bzero(&mb
.parts
, sizeof (mb
.parts
));
965 cp
= (uchar_t
*)&mb
.parts
[0];
966 /* bootable or not */
968 /* beginning CHS; 0xffffff if not representable */
974 /* ending CHS; 0xffffff if not representable */
978 /* starting LBA: 1 (little endian format) by EFI definition */
983 /* ending LBA: last block on the disk (little endian format) */
984 size_in_lba
= vtoc
->efi_last_lba
;
985 if (size_in_lba
< 0xffffffff) {
986 *cp
++ = (size_in_lba
& 0x000000ff);
987 *cp
++ = (size_in_lba
& 0x0000ff00) >> 8;
988 *cp
++ = (size_in_lba
& 0x00ff0000) >> 16;
989 *cp
++ = (size_in_lba
& 0xff000000) >> 24;
997 (void) memcpy(buf
, &mb
, sizeof (mb
));
998 /* LINTED -- always longlong aligned */
999 dk_ioc
.dki_data
= (efi_gpt_t
*)buf
;
1001 dk_ioc
.dki_length
= len
;
1002 if (efi_ioctl(fd
, DKIOCSETEFI
, &dk_ioc
) == -1) {
1017 /* make sure the user specified something reasonable */
1019 check_input(struct dk_gpt
*vtoc
)
1023 diskaddr_t istart
, jstart
, isize
, jsize
, endsect
;
1026 * Sanity-check the input (make sure no partitions overlap)
1028 for (i
= 0; i
< vtoc
->efi_nparts
; i
++) {
1029 /* It can't be unassigned and have an actual size */
1030 if ((vtoc
->efi_parts
[i
].p_tag
== V_UNASSIGNED
) &&
1031 (vtoc
->efi_parts
[i
].p_size
!= 0)) {
1033 (void) fprintf(stderr
, "partition %d is "
1034 "\"unassigned\" but has a size of %llu",
1035 i
, vtoc
->efi_parts
[i
].p_size
);
1039 if (vtoc
->efi_parts
[i
].p_tag
== V_UNASSIGNED
) {
1040 if (uuid_is_null((uchar_t
*)&vtoc
->efi_parts
[i
].p_guid
))
1042 /* we have encountered an unknown uuid */
1043 vtoc
->efi_parts
[i
].p_tag
= 0xff;
1045 if (vtoc
->efi_parts
[i
].p_tag
== V_RESERVED
) {
1046 if (resv_part
!= -1) {
1048 (void) fprintf(stderr
, "found "
1049 "duplicate reserved partition "
1056 if ((vtoc
->efi_parts
[i
].p_start
< vtoc
->efi_first_u_lba
) ||
1057 (vtoc
->efi_parts
[i
].p_start
> vtoc
->efi_last_u_lba
)) {
1059 (void) fprintf(stderr
,
1060 "Partition %d starts at %llu. ",
1062 vtoc
->efi_parts
[i
].p_start
);
1063 (void) fprintf(stderr
,
1064 "It must be between %llu and %llu.\n",
1065 vtoc
->efi_first_u_lba
,
1066 vtoc
->efi_last_u_lba
);
1070 if ((vtoc
->efi_parts
[i
].p_start
+
1071 vtoc
->efi_parts
[i
].p_size
<
1072 vtoc
->efi_first_u_lba
) ||
1073 (vtoc
->efi_parts
[i
].p_start
+
1074 vtoc
->efi_parts
[i
].p_size
>
1075 vtoc
->efi_last_u_lba
+ 1)) {
1077 (void) fprintf(stderr
,
1078 "Partition %d ends at %llu. ",
1080 vtoc
->efi_parts
[i
].p_start
+
1081 vtoc
->efi_parts
[i
].p_size
);
1082 (void) fprintf(stderr
,
1083 "It must be between %llu and %llu.\n",
1084 vtoc
->efi_first_u_lba
,
1085 vtoc
->efi_last_u_lba
);
1090 for (j
= 0; j
< vtoc
->efi_nparts
; j
++) {
1091 isize
= vtoc
->efi_parts
[i
].p_size
;
1092 jsize
= vtoc
->efi_parts
[j
].p_size
;
1093 istart
= vtoc
->efi_parts
[i
].p_start
;
1094 jstart
= vtoc
->efi_parts
[j
].p_start
;
1095 if ((i
!= j
) && (isize
!= 0) && (jsize
!= 0)) {
1096 endsect
= jstart
+ jsize
-1;
1097 if ((jstart
<= istart
) &&
1098 (istart
<= endsect
)) {
1100 (void) fprintf(stderr
,
1101 "Partition %d overlaps "
1102 "partition %d.", i
, j
);
1109 /* just a warning for now */
1110 if ((resv_part
== -1) && efi_debug
) {
1111 (void) fprintf(stderr
,
1112 "no reserved partition found\n");
1118 * add all the unallocated space to the current label
1121 efi_use_whole_disk(int fd
)
1123 struct dk_gpt
*efi_label
= NULL
;
1126 uint_t resv_index
= 0, data_index
= 0;
1127 diskaddr_t resv_start
= 0, data_start
= 0;
1128 diskaddr_t difference
;
1130 rval
= efi_alloc_and_read(fd
, &efi_label
);
1132 if (efi_label
!= NULL
)
1133 efi_free(efi_label
);
1138 * If alter_lba is 1, we are using the backup label.
1139 * Since we can locate the backup label by disk capacity,
1140 * there must be no unallocated space.
1142 if ((efi_label
->efi_altern_lba
== 1) || (efi_label
->efi_altern_lba
1143 >= efi_label
->efi_last_lba
)) {
1145 (void) fprintf(stderr
,
1146 "efi_use_whole_disk: requested space not found\n");
1148 efi_free(efi_label
);
1152 difference
= efi_label
->efi_last_lba
- efi_label
->efi_altern_lba
;
1155 * Find the last physically non-zero partition.
1156 * This is the reserved partition.
1158 for (i
= 0; i
< efi_label
->efi_nparts
; i
++) {
1159 if (resv_start
< efi_label
->efi_parts
[i
].p_start
) {
1160 resv_start
= efi_label
->efi_parts
[i
].p_start
;
1166 * Find the last physically non-zero partition before that.
1167 * This is the data partition.
1169 for (i
= 0; i
< resv_index
; i
++) {
1170 if (data_start
< efi_label
->efi_parts
[i
].p_start
) {
1171 data_start
= efi_label
->efi_parts
[i
].p_start
;
1177 * Move the reserved partition. There is currently no data in
1178 * here except fabricated devids (which get generated via
1179 * efi_write()). So there is no need to copy data.
1181 efi_label
->efi_parts
[data_index
].p_size
+= difference
;
1182 efi_label
->efi_parts
[resv_index
].p_start
+= difference
;
1183 efi_label
->efi_last_u_lba
+= difference
;
1185 rval
= efi_write(fd
, efi_label
);
1188 (void) fprintf(stderr
,
1189 "efi_use_whole_disk:fail to write label, rval=%d\n",
1192 efi_free(efi_label
);
1196 efi_free(efi_label
);
1202 * write EFI label and backup label
1205 efi_write(int fd
, struct dk_gpt
*vtoc
)
1209 efi_gpe_t
*efi_parts
;
1211 struct dk_cinfo dki_info
;
1215 diskaddr_t lba_backup_gpt_hdr
;
1217 if ((rval
= efi_get_info(fd
, &dki_info
)) != 0)
1220 /* check if we are dealing wih a metadevice */
1221 if ((strncmp(dki_info
.dki_cname
, "pseudo", 7) == 0) &&
1222 (strncmp(dki_info
.dki_dname
, "md", 3) == 0)) {
1226 if (check_input(vtoc
)) {
1228 * not valid; if it's a metadevice just pass it down
1229 * because SVM will do its own checking
1237 if (NBLOCKS(vtoc
->efi_nparts
, vtoc
->efi_lbasize
) < 34) {
1238 dk_ioc
.dki_length
= EFI_MIN_ARRAY_SIZE
+ vtoc
->efi_lbasize
;
1240 dk_ioc
.dki_length
= NBLOCKS(vtoc
->efi_nparts
,
1241 vtoc
->efi_lbasize
) *
1246 * the number of blocks occupied by GUID partition entry array
1248 nblocks
= dk_ioc
.dki_length
/ vtoc
->efi_lbasize
- 1;
1251 * Backup GPT header is located on the block after GUID
1252 * partition entry array. Here, we calculate the address
1253 * for backup GPT header.
1255 lba_backup_gpt_hdr
= vtoc
->efi_last_u_lba
+ 1 + nblocks
;
1256 if (posix_memalign((void **)&dk_ioc
.dki_data
,
1257 vtoc
->efi_lbasize
, dk_ioc
.dki_length
))
1260 memset(dk_ioc
.dki_data
, 0, dk_ioc
.dki_length
);
1261 efi
= dk_ioc
.dki_data
;
1263 /* stuff user's input into EFI struct */
1264 efi
->efi_gpt_Signature
= LE_64(EFI_SIGNATURE
);
1265 efi
->efi_gpt_Revision
= LE_32(vtoc
->efi_version
); /* 0x02000100 */
1266 efi
->efi_gpt_HeaderSize
= LE_32(sizeof (struct efi_gpt
) - LEN_EFI_PAD
);
1267 efi
->efi_gpt_Reserved1
= 0;
1268 efi
->efi_gpt_MyLBA
= LE_64(1ULL);
1269 efi
->efi_gpt_AlternateLBA
= LE_64(lba_backup_gpt_hdr
);
1270 efi
->efi_gpt_FirstUsableLBA
= LE_64(vtoc
->efi_first_u_lba
);
1271 efi
->efi_gpt_LastUsableLBA
= LE_64(vtoc
->efi_last_u_lba
);
1272 efi
->efi_gpt_PartitionEntryLBA
= LE_64(2ULL);
1273 efi
->efi_gpt_NumberOfPartitionEntries
= LE_32(vtoc
->efi_nparts
);
1274 efi
->efi_gpt_SizeOfPartitionEntry
= LE_32(sizeof (struct efi_gpe
));
1275 UUID_LE_CONVERT(efi
->efi_gpt_DiskGUID
, vtoc
->efi_disk_uguid
);
1277 /* LINTED -- always longlong aligned */
1278 efi_parts
= (efi_gpe_t
*)((char *)dk_ioc
.dki_data
+ vtoc
->efi_lbasize
);
1280 for (i
= 0; i
< vtoc
->efi_nparts
; i
++) {
1282 j
< sizeof (conversion_array
) /
1283 sizeof (struct uuid_to_ptag
); j
++) {
1285 if (vtoc
->efi_parts
[i
].p_tag
== j
) {
1287 efi_parts
[i
].efi_gpe_PartitionTypeGUID
,
1288 conversion_array
[j
].uuid
);
1293 if (j
== sizeof (conversion_array
) /
1294 sizeof (struct uuid_to_ptag
)) {
1296 * If we didn't have a matching uuid match, bail here.
1297 * Don't write a label with unknown uuid.
1300 (void) fprintf(stderr
,
1301 "Unknown uuid for p_tag %d\n",
1302 vtoc
->efi_parts
[i
].p_tag
);
1307 /* Zero's should be written for empty partitions */
1308 if (vtoc
->efi_parts
[i
].p_tag
== V_UNASSIGNED
)
1311 efi_parts
[i
].efi_gpe_StartingLBA
=
1312 LE_64(vtoc
->efi_parts
[i
].p_start
);
1313 efi_parts
[i
].efi_gpe_EndingLBA
=
1314 LE_64(vtoc
->efi_parts
[i
].p_start
+
1315 vtoc
->efi_parts
[i
].p_size
- 1);
1316 efi_parts
[i
].efi_gpe_Attributes
.PartitionAttrs
=
1317 LE_16(vtoc
->efi_parts
[i
].p_flag
);
1318 for (j
= 0; j
< EFI_PART_NAME_LEN
; j
++) {
1319 efi_parts
[i
].efi_gpe_PartitionName
[j
] =
1320 LE_16((ushort_t
)vtoc
->efi_parts
[i
].p_name
[j
]);
1322 if ((vtoc
->efi_parts
[i
].p_tag
!= V_UNASSIGNED
) &&
1323 uuid_is_null((uchar_t
*)&vtoc
->efi_parts
[i
].p_uguid
)) {
1324 (void) uuid_generate((uchar_t
*)
1325 &vtoc
->efi_parts
[i
].p_uguid
);
1327 bcopy(&vtoc
->efi_parts
[i
].p_uguid
,
1328 &efi_parts
[i
].efi_gpe_UniquePartitionGUID
,
1331 efi
->efi_gpt_PartitionEntryArrayCRC32
=
1332 LE_32(efi_crc32((unsigned char *)efi_parts
,
1333 vtoc
->efi_nparts
* (int)sizeof (struct efi_gpe
)));
1334 efi
->efi_gpt_HeaderCRC32
=
1335 LE_32(efi_crc32((unsigned char *)efi
,
1336 LE_32(efi
->efi_gpt_HeaderSize
)));
1338 if (efi_ioctl(fd
, DKIOCSETEFI
, &dk_ioc
) == -1) {
1339 free(dk_ioc
.dki_data
);
1349 /* if it's a metadevice we're done */
1351 free(dk_ioc
.dki_data
);
1355 /* write backup partition array */
1356 dk_ioc
.dki_lba
= vtoc
->efi_last_u_lba
+ 1;
1357 dk_ioc
.dki_length
-= vtoc
->efi_lbasize
;
1359 dk_ioc
.dki_data
= (efi_gpt_t
*)((char *)dk_ioc
.dki_data
+
1362 if (efi_ioctl(fd
, DKIOCSETEFI
, &dk_ioc
) == -1) {
1364 * we wrote the primary label okay, so don't fail
1367 (void) fprintf(stderr
,
1368 "write of backup partitions to block %llu "
1369 "failed, errno %d\n",
1370 vtoc
->efi_last_u_lba
+ 1,
1375 * now swap MyLBA and AlternateLBA fields and write backup
1376 * partition table header
1378 dk_ioc
.dki_lba
= lba_backup_gpt_hdr
;
1379 dk_ioc
.dki_length
= vtoc
->efi_lbasize
;
1381 dk_ioc
.dki_data
= (efi_gpt_t
*)((char *)dk_ioc
.dki_data
-
1383 efi
->efi_gpt_AlternateLBA
= LE_64(1ULL);
1384 efi
->efi_gpt_MyLBA
= LE_64(lba_backup_gpt_hdr
);
1385 efi
->efi_gpt_PartitionEntryLBA
= LE_64(vtoc
->efi_last_u_lba
+ 1);
1386 efi
->efi_gpt_HeaderCRC32
= 0;
1387 efi
->efi_gpt_HeaderCRC32
=
1388 LE_32(efi_crc32((unsigned char *)dk_ioc
.dki_data
,
1389 LE_32(efi
->efi_gpt_HeaderSize
)));
1391 if (efi_ioctl(fd
, DKIOCSETEFI
, &dk_ioc
) == -1) {
1393 (void) fprintf(stderr
,
1394 "write of backup header to block %llu failed, "
1400 /* write the PMBR */
1401 (void) write_pmbr(fd
, vtoc
);
1402 free(dk_ioc
.dki_data
);
1408 efi_free(struct dk_gpt
*ptr
)
1414 * Input: File descriptor
1415 * Output: 1 if disk has an EFI label, or > 2TB with no VTOC or legacy MBR.
1423 struct extvtoc extvtoc
;
1425 if (ioctl(fd
, DKIOCGEXTVTOC
, &extvtoc
) == -1) {
1426 if (errno
== ENOTSUP
)
1428 else if (errno
== ENOTTY
) {
1429 if (ioctl(fd
, DKIOCGVTOC
, &vtoc
) == -1)
1430 if (errno
== ENOTSUP
)
1441 efi_err_check(struct dk_gpt
*vtoc
)
1445 diskaddr_t istart
, jstart
, isize
, jsize
, endsect
;
1449 * make sure no partitions overlap
1451 for (i
= 0; i
< vtoc
->efi_nparts
; i
++) {
1452 /* It can't be unassigned and have an actual size */
1453 if ((vtoc
->efi_parts
[i
].p_tag
== V_UNASSIGNED
) &&
1454 (vtoc
->efi_parts
[i
].p_size
!= 0)) {
1455 (void) fprintf(stderr
,
1456 "partition %d is \"unassigned\" but has a size "
1457 "of %llu\n", i
, vtoc
->efi_parts
[i
].p_size
);
1459 if (vtoc
->efi_parts
[i
].p_tag
== V_UNASSIGNED
) {
1462 if (vtoc
->efi_parts
[i
].p_tag
== V_RESERVED
) {
1463 if (resv_part
!= -1) {
1464 (void) fprintf(stderr
,
1465 "found duplicate reserved partition at "
1469 if (vtoc
->efi_parts
[i
].p_size
!= EFI_MIN_RESV_SIZE
)
1470 (void) fprintf(stderr
,
1471 "Warning: reserved partition size must "
1472 "be %d sectors\n", EFI_MIN_RESV_SIZE
);
1474 if ((vtoc
->efi_parts
[i
].p_start
< vtoc
->efi_first_u_lba
) ||
1475 (vtoc
->efi_parts
[i
].p_start
> vtoc
->efi_last_u_lba
)) {
1476 (void) fprintf(stderr
,
1477 "Partition %d starts at %llu\n",
1479 vtoc
->efi_parts
[i
].p_start
);
1480 (void) fprintf(stderr
,
1481 "It must be between %llu and %llu.\n",
1482 vtoc
->efi_first_u_lba
,
1483 vtoc
->efi_last_u_lba
);
1485 if ((vtoc
->efi_parts
[i
].p_start
+
1486 vtoc
->efi_parts
[i
].p_size
<
1487 vtoc
->efi_first_u_lba
) ||
1488 (vtoc
->efi_parts
[i
].p_start
+
1489 vtoc
->efi_parts
[i
].p_size
>
1490 vtoc
->efi_last_u_lba
+ 1)) {
1491 (void) fprintf(stderr
,
1492 "Partition %d ends at %llu\n",
1494 vtoc
->efi_parts
[i
].p_start
+
1495 vtoc
->efi_parts
[i
].p_size
);
1496 (void) fprintf(stderr
,
1497 "It must be between %llu and %llu.\n",
1498 vtoc
->efi_first_u_lba
,
1499 vtoc
->efi_last_u_lba
);
1502 for (j
= 0; j
< vtoc
->efi_nparts
; j
++) {
1503 isize
= vtoc
->efi_parts
[i
].p_size
;
1504 jsize
= vtoc
->efi_parts
[j
].p_size
;
1505 istart
= vtoc
->efi_parts
[i
].p_start
;
1506 jstart
= vtoc
->efi_parts
[j
].p_start
;
1507 if ((i
!= j
) && (isize
!= 0) && (jsize
!= 0)) {
1508 endsect
= jstart
+ jsize
-1;
1509 if ((jstart
<= istart
) &&
1510 (istart
<= endsect
)) {
1512 (void) fprintf(stderr
,
1513 "label error: EFI Labels do not "
1514 "support overlapping partitions\n");
1516 (void) fprintf(stderr
,
1517 "Partition %d overlaps partition "
1524 /* make sure there is a reserved partition */
1525 if (resv_part
== -1) {
1526 (void) fprintf(stderr
,
1527 "no reserved partition found\n");
1532 * We need to get information necessary to construct a *new* efi
1536 efi_auto_sense(int fd
, struct dk_gpt
**vtoc
)
1542 * Now build the default partition table
1544 if (efi_alloc_and_init(fd
, EFI_NUMPAR
, vtoc
) != 0) {
1546 (void) fprintf(stderr
, "efi_alloc_and_init failed.\n");
1551 for (i
= 0; i
< MIN((*vtoc
)->efi_nparts
, V_NUMPAR
); i
++) {
1552 (*vtoc
)->efi_parts
[i
].p_tag
= default_vtoc_map
[i
].p_tag
;
1553 (*vtoc
)->efi_parts
[i
].p_flag
= default_vtoc_map
[i
].p_flag
;
1554 (*vtoc
)->efi_parts
[i
].p_start
= 0;
1555 (*vtoc
)->efi_parts
[i
].p_size
= 0;
1558 * Make constants first
1559 * and variable partitions later
1562 /* root partition - s0 128 MB */
1563 (*vtoc
)->efi_parts
[0].p_start
= 34;
1564 (*vtoc
)->efi_parts
[0].p_size
= 262144;
1566 /* partition - s1 128 MB */
1567 (*vtoc
)->efi_parts
[1].p_start
= 262178;
1568 (*vtoc
)->efi_parts
[1].p_size
= 262144;
1570 /* partition -s2 is NOT the Backup disk */
1571 (*vtoc
)->efi_parts
[2].p_tag
= V_UNASSIGNED
;
1573 /* partition -s6 /usr partition - HOG */
1574 (*vtoc
)->efi_parts
[6].p_start
= 524322;
1575 (*vtoc
)->efi_parts
[6].p_size
= (*vtoc
)->efi_last_u_lba
- 524322
1578 /* efi reserved partition - s9 16K */
1579 (*vtoc
)->efi_parts
[8].p_start
= (*vtoc
)->efi_last_u_lba
- (1024 * 16);
1580 (*vtoc
)->efi_parts
[8].p_size
= (1024 * 16);
1581 (*vtoc
)->efi_parts
[8].p_tag
= V_RESERVED
;