1efi_alloc_and_init(3EXT) Extended Library Functions efi_alloc_and_init(3EXT)
2
3
4
6 efi_alloc_and_init, efi_alloc_and_read, efi_free, efi_write,
7 efi_use_whole_disk - manipulate a disk's EFI Partition Table
8
10 cc [ flag ... ] file... -lefi [ library ... ]
11 #include <sys/vtoc.h>
12 #include <sys/efi_partition.h>
13
14 int efi_alloc_and_init(int fd, uint32_t nparts, dk_gpt_t **vtoc);
15
16
17 int efi_alloc_and_read(int fd, dk_gpt_t **vtoc);
18
19
20 void efi_free(dk_gpt_t *vtoc);
21
22
23 int efi_write(int fd, dk_gpt_t *vtoc);
24
25
26 int efi_use_whole_disk(int fd);
27
28
30 The efi_alloc_and_init() function initializes the dk_gpt_t structure
31 specified by vtoc in preparation for a call to efi_write(). It calcu‐
32 lates and initializes the efi_version, efi_lbasize, efi_nparts,
33 efi_first_u_lba, efi_last_lba, and efi_last_u_lba members of this
34 sturcture. The caller can then set the efi_nparts member.
35
36
37 The efi_alloc_and_read() function allocates memory and returns the par‐
38 tition table.
39
40
41 The efi_free() function frees the memory allocated by
42 efi_alloc_and_init() and efi_alloc_and_read().
43
44
45 The efi_write() function writes the EFI partition table.
46
47
48 The efi_use_whole_disk() function takes any space that is not contained
49 in the disk label and adds it to the last physically non-zero area
50 before the reserved slice (from slice 0 to slice 6 or unallocated
51 space).
52
53
54 The fd argument refers to any slice on a raw disk, opened with O_NDE‐
55 LAY. See open(2).
56
57
58 The nparts argument specifies the number of desired partitions.
59
60
61 The vtoc argument is a dk_gpt_t structure that describes an EFI parti‐
62 tion table and contains at least the following members:
63
64 uint_t efi_version; /* set to EFI_VERSION_CURRENT */
65 uint_t efi_nparts; /* number of partitions in efi_parts */
66 uint_t efi_lbasize; /* size of block in bytes */
67 diskaddr_t efi_last_lba; /* last block on the disk */
68 diskaddr_t efi_first_u_lba; /* first block after labels */
69 diskaddr_t efi_last_u_lba; /* last block before backup labels */
70 struct dk_part efi_parts[]; /* array of partitions */
71
72
74 Upon successful completion, efi_alloc_and_init() returns 0. Otherwise
75 it returns VT_EIO if an I/O operation to the disk fails.
76
77
78 Upon successful completion, efi_alloc_and_read() returns a positive
79 integer indicating the slice index associated with the open file
80 descriptor. Otherwise, it returns a negative integer to indicate one of
81 the following:
82
83 VT_EIO An I/O error occurred.
84
85
86 VT_ERROR An unknown error occurred.
87
88
89 VT_EINVAL An EFI label was not found.
90
91
92
93 Upon successful completion, efi_write() returns 0. Otherwise, it
94 returns a negative integer to indicate one of the following:
95
96 VT_EIO An I/O error occurred.
97
98
99 VT_ERROR An unknown error occurred.
100
101
102 VT_EINVAL The label contains incorrect data.
103
104
105
106 Upon successfully completion, efi_use_whole_disk() returns 0. Other‐
107 wise, it returns a negative integer to indicate one of the following:
108
109 VT_EIO An I/O error occurred.
110
111
112 VT_ERROR An unknown error occurred.
113
114
115 VT_EINVAL The label contains incorrect data.
116
117
118 VT_ENOSPC Space out of label was not found.
119
120
122 The EFI label is used on disks with more than 1^32-1 blocks. For com‐
123 patibility reasons, the read_vtoc(3EXT) and write_vtoc() functions
124 should be used on smaller disks. The application should attempt the
125 read_vtoc() or write_vtoc() call, check for an error of VT_ENOTSUP,
126 then call the analogous EFI function.
127
129 See attributes(5) for descriptions of the following attributes:
130
131
132
133
134 ┌─────────────────────────────┬─────────────────────────────┐
135 │ ATTRIBUTE TYPE │ ATTRIBUTE VALUE │
136 ├─────────────────────────────┼─────────────────────────────┤
137 │Interface Stability │Committed │
138 ├─────────────────────────────┼─────────────────────────────┤
139 │MT-Level │Unsafe │
140 └─────────────────────────────┴─────────────────────────────┘
141
143 fmthard(1M), format(1M), prtvtoc(1M), ioctl(2), open(2), libefi(3LIB),
144 read_vtoc(3EXT), attributes(5), dkio(7I)
145
146
147
148SunOS 5.11 8 May 2008 efi_alloc_and_init(3EXT)