Use GPTar table #3

Merged
reynir merged 6 commits from gptar' into main 2024-10-16 09:10:33 +00:00
Showing only changes of commit 068c640dac - Show all commits

View file

@ -114,8 +114,6 @@ module Make(BLOCK : Mirage_block.S) = struct
Lwt.return_error (`Msg "too small disk")
else Lwt_result.return ()
in
let gpt =
let partitions =
(* Current implementation of [Gpt.Partition.make] only returns [Ok _] or
raises [Invalid_argument _] :/ *)
let attributes = 1L in
@ -155,6 +153,8 @@ module Make(BLOCK : Mirage_block.S) = struct
(Int64.pred git_dump.starting_lba)
|> Result.get_ok
in
let gpt =
let partitions =
[ tar; git_dump; md5s; sha512s ]
in
Gpt.make ~sector_size ~disk_sectors:size_sectors partitions
@ -167,6 +167,23 @@ module Make(BLOCK : Mirage_block.S) = struct
Gpt.marshal_partition_table ~sector_size
(Cstruct.shift buf (sector_size * Int64.to_int gpt.partition_entry_lba))
gpt;
BLOCK.write block 0L [ buf ]
let write block sector_start buffers =
BLOCK.write block sector_start buffers
|> Lwt_result.map_error (fun e -> `Block e)
in
let*? () =
write block 0L [ buf ]
in
(* Format the file systems by writing zeroes *)
let zeroes = Cstruct.create (max (2 * Tar.Header.length) sector_size) in
let*? () =
write block tar.starting_lba [ Cstruct.sub zeroes 0 (2 * Tar.Header.length) ]
in
let*? () =
write block git_dump.starting_lba [ Cstruct.sub zeroes 0 sector_size ]
in
let*? () =
write block md5s.starting_lba [ Cstruct.sub zeroes 0 sector_size ]
in
write block sha512s.starting_lba [ Cstruct.sub zeroes 0 sector_size ]
end