class GptDevice

Defined at line 129 of file ../../src/storage/gpt/include/gpt/gpt.h

Public Methods

bool Valid ()

returns true if the partition table on the device is valid

Defined at line 143 of file ../../src/storage/gpt/include/gpt/gpt.h

uint64_t BlockSize ()

Return device's block size

Defined at line 219 of file ../../src/storage/gpt/include/gpt/gpt.h

uint32_t EntryCount ()

Defined at line 221 of file ../../src/storage/gpt/include/gpt/gpt.h

uint64_t EntryArraySize ()

Return number of bytes entries array occupies.

Defined at line 229 of file ../../src/storage/gpt/include/gpt/gpt.h

uint64_t EntryArrayBlockCount ()

Return number of blocks that entries array occupies.

Defined at line 238 of file ../../src/storage/gpt/include/gpt/gpt.h

uint64_t TotalBlockCount ()

Return total number of blocks in the device

Defined at line 243 of file ../../src/storage/gpt/include/gpt/gpt.h

zx::result<std::unique_ptr<GptDevice>> Create (std::unique_ptr<block_client::BlockDevice> device, uint32_t blocksize, uint64_t blocks)

Defined at line 719 of file ../../src/storage/gpt/gpt.cc

zx::result<std::unique_ptr<GptDevice>> Load (const uint8_t * buffer, uint64_t size, uint32_t blocksize, uint64_t blocks)

Loads gpt header and gpt entries array from |buffer| of length |size|

belonging to "block device" with |blocks| number of blocks and each

block of size |blocksize|. On finding valid header and entries, returns a GptDevice.

Defined at line 724 of file ../../src/storage/gpt/gpt.cc

zx_status_t Range (uint64_t * block_start, uint64_t * block_end)

Returns the range of usable blocks within the GPT, from [block_start, block_end] (inclusive)

Defined at line 762 of file ../../src/storage/gpt/gpt.cc

zx_status_t FindFreeRange (uint64_t blocks, uint64_t * out_offset)

Finds a contiguous series of |blocks| which are unallocated, returning the offset of the range

in |out_offset|. Returns ZX_ERR_NO_SPACE if no free range that large exists.

Defined at line 774 of file ../../src/storage/gpt/gpt.cc

zx_status_t Sync ()

Writes changes to partition table to the device. If the device does not contain valid

GPT, a gpt header gets created. Sync doesn't nudge block device driver to rescan the

partitions. So it is the caller's responsibility to rescan partitions for the changes

if needed.

Defined at line 760 of file ../../src/storage/gpt/gpt.cc

zx_status_t Finalize ()

perform all checks and computations on the in-memory representation, but DOES

NOT write it out to disk. To perform checks AND write to disk, use Sync

Defined at line 758 of file ../../src/storage/gpt/gpt.cc

zx::result<uint32_t> AddPartition (const char * name, const uint8_t * type, const uint8_t * guid, uint64_t offset, uint64_t blocks, uint64_t flags)

Adds a partition to in-memory instance of GptDevice. The changes stay visible

only to this instance. Needs a Sync to write the changes to the device.

Returns the partition's index.

Defined at line 812 of file ../../src/storage/gpt/gpt.cc

zx_status_t ClearPartition (uint64_t offset, uint64_t blocks)

Writes zeroed blocks at an arbitrary offset (in blocks) within the device.

Can be used alongside gpt_partition_add to ensure a newly created partition

will not read stale superblock data.

Defined at line 883 of file ../../src/storage/gpt/gpt.cc

zx_status_t RemovePartition (const uint8_t * guid)

Removes a partition from in-memory instance of GptDevice. The changes stay visible

only to this instace. Needs a Sync to write the changes to the device.

Defined at line 922 of file ../../src/storage/gpt/gpt.cc

zx_status_t RemoveAllPartitions ()

Removes all partitions from in-memory instance of GptDevice. The changes stay visible

only to this instace. Needs a Sync to write the changes to the device.

Defined at line 947 of file ../../src/storage/gpt/gpt.cc

void GetHeaderGuid (uint8_t (*)[16] disk_guid_out)

given a gpt device, get the GUID for the disk

Defined at line 1044 of file ../../src/storage/gpt/gpt.cc

zx_status_t GetDiffs (uint32_t idx, uint32_t * diffs)

return true if partition# idx has been locally modified

Defined at line 637 of file ../../src/storage/gpt/gpt.cc

zx::result<gpt_partition_t *> GetPartition (uint32_t partition_index)

Returns mutable pointer to partition entry at given index, otherwise ZX_ERR_NOT_FOUND

if the partition entry is nullptr, or ZX_ERR_OUT_OF_RANGE if the index is out of range.

Defined at line 960 of file ../../src/storage/gpt/gpt.cc

zx::result<const gpt_partition_t *> GetPartition (uint32_t partition_index)

Returns const pointer to partition entry at given index, otherwise ZX_ERR_NOT_FOUND

if the partition entry is nullptr, or ZX_ERR_OUT_OF_RANGE if the index is out of range.

Defined at line 964 of file ../../src/storage/gpt/gpt.cc

zx_status_t SetPartitionType (uint32_t partition_index, const uint8_t * type)

Updates the type of partition at index partition_index

Defined at line 968 of file ../../src/storage/gpt/gpt.cc

zx_status_t SetPartitionGuid (uint32_t partition_index, const uint8_t * guid)

Updates the guid(id) of partition at index partition_index

Defined at line 976 of file ../../src/storage/gpt/gpt.cc

zx_status_t SetPartitionVisibility (uint32_t partition_index, bool visible)

Makes partition visible if 'visible' is true

Defined at line 984 of file ../../src/storage/gpt/gpt.cc

zx_status_t SetPartitionRange (uint32_t partition_index, uint64_t start, uint64_t end)

Changes partition's partitions start and end blocks. If there is conflict with

either other partitions or the device, then returns non-ZX_OK value

Defined at line 992 of file ../../src/storage/gpt/gpt.cc

zx_status_t GetPartitionFlags (uint32_t partition_index, uint64_t * flags)

Returns current flags for partition at index partition_index

Defined at line 1027 of file ../../src/storage/gpt/gpt.cc

zx_status_t SetPartitionFlags (uint32_t partition_index, uint64_t flags)

Sets flags for partition at index partition_index

Defined at line 1036 of file ../../src/storage/gpt/gpt.cc

void PrintTable ()

print out the GPT

Defined at line 524 of file ../../src/storage/gpt/gpt.cc

block_client::BlockDevice & device ()

Defined at line 1048 of file ../../src/storage/gpt/gpt.cc