Library
Module
Module type
Parameter
Class
Class type
module Partition : sig ... end
type t = private {
revision : int32;
header_size : int32;
header_crc32 : int32;
reserved : int32;
current_lba : int64;
backup_lba : int64;
first_usable_lba : int64;
last_usable_lba : int64;
disk_guid : Uuidm.t;
partition_entry_lba : int64;
num_partition_entries : int32;
partition_size : int32;
partitions_crc32 : int32;
partitions : Partition.t list;
}
val make :
?disk_guid:Uuidm.t ->
disk_sectors:int64 ->
sector_size:int ->
Partition.t list ->
(t, string) Stdlib.result
make ?disk_guid ~disk_sectors ~sector_size partitions
constructs a GPT given a desired list of partitions. The header is assumed to be written in LBA 1, and the partition table is written from LBA 2 with 128 partition entries allocated. The backup header is assumed written in the last LBA. An Error _
is returned if the number of partitions exceeds 128, or any of the partitions overlap with each other or the first sector,
The optional argument disk_guid
specifies the disk guid to be written in the GPT. If disk_guid
is not provided, a random value is used.
val unmarshal :
Cstruct.t ->
sector_size:int ->
([ `Read_partition_table of int64 * int ]
* (Cstruct.t ->
(t, string) Stdlib.result),
string)
Stdlib.result
unmarshal ~sector_size buf
on success is a pair (`Read_partition (lba, num_sectors), k)
where lba
is the logical block address (sector) to read num_sectors
sectors of the partition table. The bytes read should then be passed to k
which then on success returns the GPT header and the partition table. An Error _
is returned when any field has an unexpected value or the checksums are wrong.
val marshal_header : sector_size:int -> primary:bool -> Cstruct.t -> t -> unit
marshal_header ~sector_size ~primary buf t
serializes the GPT header to buf
. The caller is expected to write the contents of buf
to t.current_lba
and t.backup_lba
. If primary
is true (default) t
is marshaled as is. Otherwise t.current_lba
and t.backup_lba
are swapped and t.header_crc32
is recomputedd.
val marshal_partition_table : sector_size:int -> Cstruct.t -> t -> unit
marshal_partition_table ~sector_size buf t
serializes the GPT partition table to buf
. The caller is expected to write the contents of buf
to t.partition_entry_lba
.