SpaceOS block storage layout
OCaml 95.3%
Dune 1.5%
Other 3.2%
8 1 0

Clone this repository

https://tangled.org/gazagnaire.org/space-block https://tangled.org/did:plc:jhift2vwcxhou52p3sewcrpx/space-block
git@git.recoil.org:gazagnaire.org/space-block git@git.recoil.org:did:plc:jhift2vwcxhou52p3sewcrpx/space-block

For self-hosted knots, clone URLs may differ based on your setup.

Download tar.gz
README.md

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 type t and operations for each storage area:
    • v / open_ -- create or open a block device with the SpaceOS layout
    • put_param / param / latest_params -- parameter store with generational versioning (highest generation wins)
    • write_event / recent_events / event_count -- event log ring buffer
    • write_dp_data / read_dp_data / dp_catalog / dp -- data product storage with CRC-32C validation
    • pp -- pretty-printer showing the full storage layout summary