2 .\" Copyright (c) 2008, Sun Microsystems, Inc. All Rights Reserved.
3 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
4 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
5 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
6 .TH EFI_ALLOC_AND_INIT 3EXT "April 9, 2016"
8 efi_alloc_and_init, efi_alloc_and_read, efi_free, efi_write, efi_use_whole_disk
9 \- manipulate a disk's EFI Partition Table
13 cc [ \fIflag \&.\|.\|.\fR ] \fIfile\fR\&.\|.\|. \fB-lefi\fR [ \fIlibrary \&.\|.\|.\fR ]
15 #include <sys/efi_partition.h>
17 \fBint\fR \fBefi_alloc_and_init\fR(\fBint\fR \fIfd\fR, \fBuint32_t\fR \fInparts\fR, \fBdk_gpt_t **\fR\fIvtoc\fR);
22 \fBint\fR \fBefi_alloc_and_read\fR(\fBint\fR \fIfd\fR, \fBdk_gpt_t **\fR\fIvtoc\fR);
27 \fBvoid\fR \fBefi_free\fR(\fBdk_gpt_t *\fR\fIvtoc\fR);
32 \fBint\fR \fBefi_write\fR(\fBint\fR \fIfd\fR, \fBdk_gpt_t *\fR\fIvtoc\fR);
37 \fBint\fR \fBefi_use_whole_disk\fR(\fBint\fR \fIfd\fR);
42 The \fBefi_alloc_and_init()\fR function initializes the \fBdk_gpt_t\fR
43 structure specified by \fIvtoc\fR in preparation for a call to
44 \fBefi_write()\fR. It calculates and initializes the \fBefi_version\fR,
45 \fBefi_lbasize\fR, \fBefi_nparts\fR, \fBefi_first_u_lba\fR, \fBefi_last_lba\fR,
46 and \fBefi_last_u_lba\fR members of this structure. The caller can then set the
47 \fBefi_nparts\fR member.
50 The \fBefi_alloc_and_read()\fR function allocates memory and returns the
54 The \fBefi_free()\fR function frees the memory allocated by
55 \fBefi_alloc_and_init()\fR and \fBefi_alloc_and_read()\fR.
58 The \fBefi_write()\fR function writes the EFI partition table.
61 The \fBefi_use_whole_disk()\fR function takes any space that is not contained
62 in the disk label and adds it to the last physically non-zero area before the
63 reserved slice (from slice 0 to slice 6 or unallocated space).
66 The \fIfd\fR argument refers to any slice on a raw disk, opened with
67 \fBO_NDELAY\fR. See \fBopen\fR(2).
70 The \fInparts\fR argument specifies the number of desired partitions.
73 The \fIvtoc\fR argument is a \fBdk_gpt_t\fR structure that describes an EFI
74 partition table and contains at least the following members:
78 uint_t efi_version; /* set to EFI_VERSION_CURRENT */
79 uint_t efi_nparts; /* number of partitions in efi_parts */
80 uint_t efi_lbasize; /* size of block in bytes */
81 diskaddr_t efi_last_lba; /* last block on the disk */
82 diskaddr_t efi_first_u_lba; /* first block after labels */
83 diskaddr_t efi_last_u_lba; /* last block before backup labels */
84 struct dk_part efi_parts[]; /* array of partitions */
90 Upon successful completion, \fBefi_alloc_and_init()\fR returns 0. Otherwise it
91 returns \fBVT_EIO\fR if an I/O operation to the disk fails.
94 Upon successful completion, \fBefi_alloc_and_read()\fR returns a positive
95 integer indicating the slice index associated with the open file descriptor.
96 Otherwise, it returns a negative integer to indicate one of the following:
103 An I/O error occurred.
112 An unknown error occurred.
118 \fB\fBVT_EINVAL\fR\fR
121 An EFI label was not found.
126 Upon successful completion, \fBefi_write()\fR returns 0. Otherwise, it returns
127 a negative integer to indicate one of the following:
134 An I/O error occurred.
143 An unknown error occurred.
149 \fB\fBVT_EINVAL\fR\fR
152 The label contains incorrect data.
157 Upon successfully completion, \fBefi_use_whole_disk()\fR returns 0. Otherwise,
158 it returns a negative integer to indicate one of the following:
165 An I/O error occurred.
174 An unknown error occurred.
180 \fB\fBVT_EINVAL\fR\fR
183 The label contains incorrect data.
189 \fB\fBVT_ENOSPC\fR\fR
192 Space out of label was not found.
197 The EFI label is used on disks with more than 1^32-1 blocks. For compatibility
198 reasons, the \fBread_vtoc\fR(3EXT) and \fBwrite_vtoc()\fR functions should be
199 used on smaller disks. The application should attempt the \fBread_vtoc()\fR or
200 \fBwrite_vtoc()\fR call, check for an error of \fBVT_ENOTSUP\fR, then call the
201 analogous EFI function.
204 See \fBattributes\fR(5) for descriptions of the following attributes:
212 ATTRIBUTE TYPE ATTRIBUTE VALUE
214 Interface Stability Committed
221 \fBfmthard\fR(1M), \fBformat\fR(1M), \fBprtvtoc\fR(1M), \fBioctl\fR(2),
222 \fBopen\fR(2), \fBlibefi\fR(3LIB), \fBread_vtoc\fR(3EXT), \fBattributes\fR(5),