space-block#
SpaceOS block storage layout.
space-block manages the SpaceOS storage layout on virtio-blk devices. It
wraps a Block.t handle and partitions it into four areas: a 48-byte
superblock (block 0), a parameter store (blocks 1--16, 252-byte entries with
generational versioning), an event log ring buffer (blocks 17--32, 76-byte
records), and a data product area (blocks 33+). All on-disk structures use
CRC-32C integrity checks and are encoded with the space-wire codecs.
The package also ships a CLI tool (space-block) with three subcommands:
init to create and initialize a storage file, inspect to dump the
superblock and layout, and launch to initialize storage and boot a QEMU VM
with the file attached as a virtio-blk drive.
Installation#
opam install space-block
Usage#
(* Initialize a new block device with the SpaceOS layout *)
let blk = Block.of_file ~sw path ~sector_size:512 () in
match Space_block.v blk ~tenant_id:1 ~uuid ~epoch with
| Ok t ->
(* Write a parameter *)
Space_block.put_param t ~id:42 "3.14159" |> Result.get_ok;
(* Write an event *)
let ev = Space_wire.Event_log.v ~timestamp:0 INFO ~event_code:1 "boot" in
Space_block.write_event t ev |> Result.get_ok;
(* Store a data product *)
let dp =
Space_block.write_dp_data t ~dp_class:1 ~priority:2
~name:"science/thermal.dat" data
in
ignore dp
| Error e -> failwith e
CLI#
space-block init --file /tmp/spaceos.img --blocks 256
space-block inspect --file /tmp/spaceos.img
space-block launch --file /tmp/spaceos.img --kernel vmlinuz --initrd initramfs.cpio
API#
Space_block-- main module providing the storage handle typetand operations for each storage area:v/open_-- create or open a block device with the SpaceOS layoutput_param/param/latest_params-- parameter store with generational versioning (highest generation wins)write_event/recent_events/event_count-- event log ring bufferwrite_dp_data/read_dp_data/dp_catalog/dp-- data product storage with CRC-32C validationpp-- pretty-printer showing the full storage layout summary