summaryrefslogtreecommitdiff
path: root/usr/src/man/man3ext/efi_alloc_and_init.3ext
blob: 394569cbe46580b8049af3b4227dafdfeda59887 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
'\" te
.\" Copyright (c) 2008, Sun Microsystems, Inc. All Rights Reserved.
.\" 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.
.\" 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.
.\" 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]
.TH efi_alloc_and_init 3EXT "8 May 2008" "SunOS 5.11" "Extended Library Functions"
.SH NAME
efi_alloc_and_init, efi_alloc_and_read, efi_free, efi_write, efi_use_whole_disk
\- manipulate a disk's EFI Partition Table
.SH SYNOPSIS
.LP
.nf
cc [ \fIflag \&.\|.\|.\fR ] \fIfile\fR\&.\|.\|. \fB-lefi\fR [ \fIlibrary \&.\|.\|.\fR ]
#include <sys/vtoc.h>
#include <sys/efi_partition.h>

\fBint\fR \fBefi_alloc_and_init\fR(\fBint\fR \fIfd\fR, \fBuint32_t\fR \fInparts\fR, \fBdk_gpt_t **\fR\fIvtoc\fR);
.fi

.LP
.nf
\fBint\fR \fBefi_alloc_and_read\fR(\fBint\fR \fIfd\fR, \fBdk_gpt_t **\fR\fIvtoc\fR);
.fi

.LP
.nf
\fBvoid\fR \fBefi_free\fR(\fBdk_gpt_t *\fR\fIvtoc\fR);
.fi

.LP
.nf
\fBint\fR \fBefi_write\fR(\fBint\fR \fIfd\fR, \fBdk_gpt_t *\fR\fIvtoc\fR);
.fi

.LP
.nf
\fBint\fR \fBefi_use_whole_disk\fR(\fBint\fR \fIfd\fR);
.fi

.SH DESCRIPTION
.sp
.LP
The \fBefi_alloc_and_init()\fR function initializes the \fBdk_gpt_t\fR
structure specified by \fIvtoc\fR in preparation for a call to
\fBefi_write()\fR. It calculates and initializes the \fBefi_version\fR,
\fBefi_lbasize\fR, \fBefi_nparts\fR, \fBefi_first_u_lba\fR, \fBefi_last_lba\fR,
and \fBefi_last_u_lba\fR members of this sturcture. The caller can then set the
\fBefi_nparts\fR member.
.sp
.LP
The \fBefi_alloc_and_read()\fR function allocates memory and returns the
partition table.
.sp
.LP
The \fBefi_free()\fR function frees the memory allocated by
\fBefi_alloc_and_init()\fR and \fBefi_alloc_and_read()\fR.
.sp
.LP
The \fBefi_write()\fR function writes the EFI partition table.
.sp
.LP
The \fBefi_use_whole_disk()\fR function takes any space that is not contained
in the disk label and adds it to the last physically non-zero area before the
reserved slice (from slice 0 to slice 6 or unallocated space).
.sp
.LP
The \fIfd\fR argument refers to any slice on a raw disk, opened with
\fBO_NDELAY\fR. See \fBopen\fR(2).
.sp
.LP
The \fInparts\fR argument specifies the number of desired partitions.
.sp
.LP
The \fIvtoc\fR argument is a \fBdk_gpt_t\fR structure that describes an EFI
partition table and contains at least the following members:
.sp
.in +2
.nf
uint_t          efi_version;     /* set to EFI_VERSION_CURRENT */
uint_t          efi_nparts;      /* number of partitions in efi_parts */
uint_t          efi_lbasize;     /* size of block in bytes */
diskaddr_t      efi_last_lba;    /* last block on the disk */
diskaddr_t      efi_first_u_lba; /* first block after labels */
diskaddr_t      efi_last_u_lba;  /* last block before backup labels */
struct dk_part  efi_parts[];     /* array of partitions */
.fi
.in -2

.SH RETURN VALUES
.sp
.LP
Upon successful completion, \fBefi_alloc_and_init()\fR returns 0. Otherwise it
returns \fBVT_EIO\fR if an I/O operation to the disk fails.
.sp
.LP
Upon successful completion, \fBefi_alloc_and_read()\fR returns a positive
integer indicating the slice index associated with the open file descriptor.
Otherwise, it returns a negative integer to indicate one of the following:
.sp
.ne 2
.mk
.na
\fB\fBVT_EIO\fR\fR
.ad
.RS 13n
.rt  
An I/O error occurred.
.RE

.sp
.ne 2
.mk
.na
\fB\fBVT_ERROR\fR\fR
.ad
.RS 13n
.rt  
An unknown error occurred.
.RE

.sp
.ne 2
.mk
.na
\fB\fBVT_EINVAL\fR\fR
.ad
.RS 13n
.rt  
An EFI label was not found.
.RE

.sp
.LP
Upon successful completion, \fBefi_write()\fR returns 0. Otherwise, it returns
a negative integer to indicate one of the following:
.sp
.ne 2
.mk
.na
\fB\fBVT_EIO\fR\fR
.ad
.RS 13n
.rt  
An I/O error occurred.
.RE

.sp
.ne 2
.mk
.na
\fB\fBVT_ERROR\fR\fR
.ad
.RS 13n
.rt  
An unknown error occurred.
.RE

.sp
.ne 2
.mk
.na
\fB\fBVT_EINVAL\fR\fR
.ad
.RS 13n
.rt  
The label contains incorrect data.
.RE

.sp
.LP
Upon successfully completion, \fBefi_use_whole_disk()\fR returns 0. Otherwise,
it returns a negative integer to indicate one of the following:
.sp
.ne 2
.mk
.na
\fB\fBVT_EIO\fR\fR
.ad
.RS 13n
.rt  
An I/O error occurred.
.RE

.sp
.ne 2
.mk
.na
\fB\fBVT_ERROR\fR\fR
.ad
.RS 13n
.rt  
An unknown error occurred.
.RE

.sp
.ne 2
.mk
.na
\fB\fBVT_EINVAL\fR\fR
.ad
.RS 13n
.rt  
The label contains incorrect data.
.RE

.sp
.ne 2
.mk
.na
\fB\fBVT_ENOSPC\fR\fR
.ad
.RS 13n
.rt  
Space out of label was not found.
.RE

.SH USAGE
.sp
.LP
The EFI label is used on disks with more than 1^32-1 blocks. For compatibility
reasons, the \fBread_vtoc\fR(3EXT) and \fBwrite_vtoc()\fR functions should be
used on smaller disks. The application should attempt the \fBread_vtoc()\fR or
\fBwrite_vtoc()\fR call, check for an error of \fBVT_ENOTSUP\fR, then call the
analogous EFI function.
.SH ATTRIBUTES
.sp
.LP
See \fBattributes\fR(5) for descriptions of the following attributes:
.sp

.sp
.TS
tab() box;
cw(2.75i) |cw(2.75i) 
lw(2.75i) |lw(2.75i) 
.
ATTRIBUTE TYPEATTRIBUTE VALUE
_
Interface StabilityCommitted
_
MT-LevelUnsafe
.TE

.SH SEE ALSO
.sp
.LP
\fBfmthard\fR(1M), \fBformat\fR(1M), \fBprtvtoc\fR(1M), \fBioctl\fR(2),
\fBopen\fR(2), \fBlibefi\fR(3LIB), \fBread_vtoc\fR(3EXT), \fBattributes\fR(5),
\fBdkio\fR(7I)