Block device abstraction for OCaml 5 with Eio direct-style I/O and Bytesrw integration
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

feat(qemu,pid1,space): two-VM infrastructure with chardev, IPC, and cross-build

Add chardev/channel/socket-serial support to ocaml-qemu so QEMU VMs
can expose virtio-serial IPC ports and redirect consoles to Unix
sockets. Update pid1 init to read IPC frames from P0 and store them
as events in the block device. Add Block.of_file ?sectors override
for Linux block devices that report st_size=0. Wire up space build
and run commands for the two-partition (P0 flight + P1 SpaceOS) demo
with Docker cross-compilation of both binaries.

+15 -5
+9 -4
lib/block.ml
··· 201 201 Eio.Resource.close t.file) 202 202 end 203 203 204 - let of_file ~sw path ~sector_size ?create () = 204 + let of_file ~sw path ~sector_size ?sectors:sectors_override ?create () = 205 205 if sector_size < 512 || sector_size land (sector_size - 1) <> 0 then 206 206 invalid_arg "sector_size must be power of 2 and >= 512"; 207 207 let file = ··· 216 216 Eio.Path.open_out ~sw path ~create:`Never |> fun f -> 217 217 (f :> Eio.File.rw_ty Eio.Resource.t) 218 218 in 219 - let stat = Eio.File.stat file in 220 - let size = Optint.Int63.to_int64 stat.size in 221 - let sectors = Int64.div size (Int64.of_int sector_size) in 219 + let sectors = 220 + match sectors_override with 221 + | Some s -> s 222 + | None -> 223 + let stat = Eio.File.stat file in 224 + let size = Optint.Int63.to_int64 stat.size in 225 + Int64.div size (Int64.of_int sector_size) 226 + in 222 227 let state = { File.file; sector_size; sectors; closed = false } in 223 228 T { state; impl = (module File) } 224 229
+6 -1
lib/block.mli
··· 109 109 sw:Eio.Switch.t -> 110 110 _ Eio.Path.t -> 111 111 sector_size:int -> 112 + ?sectors:int64 -> 112 113 ?create:int64 -> 113 114 unit -> 114 115 t 115 - (** [of_file ~sw path ~sector_size ?create ()] opens a file as a block device. 116 + (** [of_file ~sw path ~sector_size ?sectors ?create ()] opens a file as a block 117 + device. 116 118 119 + @param sectors 120 + Override the sector count instead of deriving it from file size. Required 121 + for Linux block devices which report [st_size = 0]. 117 122 @param create 118 123 If provided, creates the file with this many sectors if it doesn't exist. 119 124 @param sector_size Sector size in bytes (must be power of 2, >= 512). *)