7139 Sync mDNS with mDNSResponder-625.41.2
[unleashed.git] / usr / src / man / man3ext / efi_alloc_and_init.3ext
blobad820788694d8fad49847b8f65f3f5f3287c4293
1 '\" te
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"
7 .SH NAME
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
10 .SH SYNOPSIS
11 .LP
12 .nf
13 cc [ \fIflag \&.\|.\|.\fR ] \fIfile\fR\&.\|.\|. \fB-lefi\fR [ \fIlibrary \&.\|.\|.\fR ]
14 #include <sys/vtoc.h>
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);
18 .fi
20 .LP
21 .nf
22 \fBint\fR \fBefi_alloc_and_read\fR(\fBint\fR \fIfd\fR, \fBdk_gpt_t **\fR\fIvtoc\fR);
23 .fi
25 .LP
26 .nf
27 \fBvoid\fR \fBefi_free\fR(\fBdk_gpt_t *\fR\fIvtoc\fR);
28 .fi
30 .LP
31 .nf
32 \fBint\fR \fBefi_write\fR(\fBint\fR \fIfd\fR, \fBdk_gpt_t *\fR\fIvtoc\fR);
33 .fi
35 .LP
36 .nf
37 \fBint\fR \fBefi_use_whole_disk\fR(\fBint\fR \fIfd\fR);
38 .fi
40 .SH DESCRIPTION
41 .LP
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.
48 .sp
49 .LP
50 The \fBefi_alloc_and_read()\fR function allocates memory and returns the
51 partition table.
52 .sp
53 .LP
54 The \fBefi_free()\fR function frees the memory allocated by
55 \fBefi_alloc_and_init()\fR and \fBefi_alloc_and_read()\fR.
56 .sp
57 .LP
58 The \fBefi_write()\fR function writes the EFI partition table.
59 .sp
60 .LP
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).
64 .sp
65 .LP
66 The \fIfd\fR argument refers to any slice on a raw disk, opened with
67 \fBO_NDELAY\fR. See \fBopen\fR(2).
68 .sp
69 .LP
70 The \fInparts\fR argument specifies the number of desired partitions.
71 .sp
72 .LP
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:
75 .sp
76 .in +2
77 .nf
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 */
85 .fi
86 .in -2
88 .SH RETURN VALUES
89 .LP
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.
92 .sp
93 .LP
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:
97 .sp
98 .ne 2
99 .na
100 \fB\fBVT_EIO\fR\fR
102 .RS 13n
103 An I/O error occurred.
107 .ne 2
109 \fB\fBVT_ERROR\fR\fR
111 .RS 13n
112 An unknown error occurred.
116 .ne 2
118 \fB\fBVT_EINVAL\fR\fR
120 .RS 13n
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:
129 .ne 2
131 \fB\fBVT_EIO\fR\fR
133 .RS 13n
134 An I/O error occurred.
138 .ne 2
140 \fB\fBVT_ERROR\fR\fR
142 .RS 13n
143 An unknown error occurred.
147 .ne 2
149 \fB\fBVT_EINVAL\fR\fR
151 .RS 13n
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:
160 .ne 2
162 \fB\fBVT_EIO\fR\fR
164 .RS 13n
165 An I/O error occurred.
169 .ne 2
171 \fB\fBVT_ERROR\fR\fR
173 .RS 13n
174 An unknown error occurred.
178 .ne 2
180 \fB\fBVT_EINVAL\fR\fR
182 .RS 13n
183 The label contains incorrect data.
187 .ne 2
189 \fB\fBVT_ENOSPC\fR\fR
191 .RS 13n
192 Space out of label was not found.
195 .SH USAGE
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.
202 .SH ATTRIBUTES
204 See \fBattributes\fR(5) for descriptions of the following attributes:
209 box;
210 c | c
211 l | l .
212 ATTRIBUTE TYPE  ATTRIBUTE VALUE
214 Interface Stability     Committed
216 MT-Level        Unsafe
219 .SH SEE ALSO
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),
223 \fBdkio\fR(7I)