Minimal bootable disk image builder
0
fork

Configure Feed

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

feat: add space-block, ocaml-pid1, qemu aarch64 support, uniboot initramfs

- ocaml-qemu: add arch/accel/machine/cpu config for macOS/aarch64
(HVF, virt machine, virtio MMIO devices), auto-detect host platform
- space-block: new package wrapping Block.t with SpaceOS storage layout
(superblock, params, events, DP), CLI with init/inspect/launch
- ocaml-pid1: minimal PID 1 for SpaceOS VMs with C stubs for mount(2)
and reboot(2), Eio filesystem I/O, standalone superblock reader
- uniboot: implement Initramfs content building from paths using cpio

+74 -5
+1 -1
lib/dune
··· 1 1 (library 2 2 (name uniboot) 3 3 (public_name uniboot) 4 - (libraries bytesrw gpt mbr squashfs cpio fmt logs uuidm)) 4 + (libraries bytesrw gpt mbr squashfs cpio fmt logs uuidm unix))
+73 -4
lib/uniboot.ml
··· 138 138 | Kernel path -> 139 139 Log.info (fun m -> m "Writing kernel from %s" path); 140 140 write_file writer path size_bytes 141 - | Initramfs _paths -> 142 - (* TODO: Build cpio archive from paths *) 143 - Log.warn (fun m -> m "Initramfs building not yet implemented"); 144 - write_zeros writer size_bytes 141 + | Initramfs paths -> 142 + Log.info (fun m -> 143 + m "Building initramfs from %d paths" (List.length paths)); 144 + let entries = 145 + List.concat_map 146 + (fun path -> 147 + if Sys.is_directory path then begin 148 + (* Add directory and its contents recursively *) 149 + let entries = ref [] in 150 + let rec walk prefix dir = 151 + let items = Sys.readdir dir |> Array.to_list in 152 + List.iter 153 + (fun name -> 154 + let full = Filename.concat dir name in 155 + let cpio_name = Filename.concat prefix name in 156 + if Sys.is_directory full then begin 157 + entries := 158 + Cpio.directory ~perm:0o755 cpio_name :: !entries; 159 + walk cpio_name full 160 + end 161 + else 162 + let data = 163 + let ic = open_in_bin full in 164 + let len = in_channel_length ic in 165 + let s = Bytes.create len in 166 + really_input ic s 0 len; 167 + close_in ic; 168 + Bytes.unsafe_to_string s 169 + in 170 + let perm = 171 + let st = Unix.stat full in 172 + st.Unix.st_perm 173 + in 174 + entries := 175 + Cpio.regular ~perm ~name:cpio_name data :: !entries) 176 + items 177 + in 178 + let base = Filename.basename path in 179 + entries := Cpio.directory ~perm:0o755 base :: !entries; 180 + walk base path; 181 + List.rev !entries 182 + end 183 + else 184 + let data = 185 + let ic = open_in_bin path in 186 + let len = in_channel_length ic in 187 + let s = Bytes.create len in 188 + really_input ic s 0 len; 189 + close_in ic; 190 + Bytes.unsafe_to_string s 191 + in 192 + let name = Filename.basename path in 193 + let perm = 194 + let st = Unix.stat path in 195 + st.Unix.st_perm 196 + in 197 + [ Cpio.regular ~perm ~name data ]) 198 + paths 199 + in 200 + let archive = Cpio.to_string entries in 201 + let archive_len = String.length archive in 202 + Log.info (fun m -> 203 + m "Initramfs: %d entries, %d bytes" (List.length entries) archive_len); 204 + if archive_len <= size_bytes then begin 205 + Writer.write writer (Slice.of_string archive); 206 + write_zeros writer (size_bytes - archive_len) 207 + end 208 + else begin 209 + Log.warn (fun m -> 210 + m "Initramfs (%d bytes) exceeds partition size (%d bytes)" 211 + archive_len size_bytes); 212 + Writer.write writer (Slice.of_string (String.sub archive 0 size_bytes)) 213 + end 145 214 | Squashfs _paths -> 146 215 (* TODO: Build squashfs from paths *) 147 216 Log.warn (fun m -> m "Squashfs building not yet implemented");