EFI_ALLOC_AND_INIT(3EXT) | Extended Library Functions | EFI_ALLOC_AND_INIT(3EXT) |
cc [ flag ... ] file... -lefi [ library ... ] #include <sys/vtoc.h> #include <sys/efi_partition.h> int efi_alloc_and_init(int fd, uint32_t nparts, dk_gpt_t **vtoc);
int efi_alloc_and_read(int fd, dk_gpt_t **vtoc);
void efi_free(dk_gpt_t *vtoc);
int efi_write(int fd, dk_gpt_t *vtoc);
int efi_use_whole_disk(int fd);
uint_t efi_reserved_sectors(dk_gpt_t *vtoc);
The efi_alloc_and_read() function allocates memory and returns the partition table.
The efi_free() function frees the memory allocated by efi_alloc_and_init() and efi_alloc_and_read().
The efi_write() function writes the EFI partition table and creates a Protective Master Boot Record (PMBR); see below.
The efi_use_whole_disk() 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).
The efi_reserved_sectors() function calculates number of sectors needed to create the reserved partition. The reserved partition is used by the operating system for internal purposes. The sector size used is based on the device and is recorded in the efi_lbasize member of the dkgpt_t structure indicated by the vtoc argument. A full description of the dk_gpt_t structure appears later in the manual.
The fd argument refers to any slice on a raw disk, opened with O_NDELAY. See open(2).
The nparts argument specifies the number of desired partitions.
The vtoc argument is a dk_gpt_t structure that describes an EFI partition table and contains at least the following members:
uint_t efi_version; /* set to EFI_VERSION_CURRENT */ uint_t efi_nparts; /* no. 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 */
Upon successful completion, efi_alloc_and_read() 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:
VT_EIO
VT_ERROR
VT_EINVAL
The efi_reserved_sectors() function always returns the number of reserved sectors required. It will always succeed.
Upon successful completion, efi_write() returns 0. Otherwise, it returns a negative integer to indicate one of the following:
VT_EIO
VT_ERROR
VT_EINVAL
Upon successfully completion, efi_use_whole_disk() returns 0. Otherwise, it returns a negative integer to indicate one of the following:
VT_EIO
VT_ERROR
VT_EINVAL
VT_ENOSPC
ATTRIBUTE TYPE | ATTRIBUTE VALUE |
Interface Stability | Committed |
MT-Level | Unsafe |
May 16, 2020 |