Follow-up to the monorepo re-org. Suite 35/35 plus host tests green. POSIX compatibility is now its own library, library/posix/ (unistd, stdio), layered strictly over the runtime — it calls the runtime's IPC/heap, never system calls directly. The runtime is now POSIX-free (the danos-native application ABI). The VFS wire protocol is danos-native throughout (Stat -> FileStatus, .stat -> .status, O_CREAT -> create); the POSIX layer maps the POSIX spellings at the boundary. The coding standard's ABI-name exception is scoped to one place: a file is allowed POSIX spellings only if it lives under library/posix/ — everywhere else, danos naming with no exception. Naming fixes, all mechanical: - initrd -> initial-ramdisk: the source file, the module, the tool (make-initial-ramdisk.py), the artifact (initial-ramdisk.img, including the bootloader's load path), and the identifiers. - system/kernel/device-service.zig -> devices-broker.zig: it is ring-0 kernel code (the trusted device table + claim capability), not a ring-3 service. The future user-space device *manager* (policy) will live in system/services/. - Dropped the daemon `d` suffix: hpetd -> hpet, busd -> bus. A driver lives in system/drivers/, so the folder already says what it is; encoding the role in the name too is redundant. The coding standard drops that exception. - system/devices/aml/interp.zig -> interpreter.zig (the type was already Interpreter).
48 lines
1.5 KiB
Zig
48 lines
1.5 KiB
Zig
//! /sbin/vfstest — a client that proves the VFS round trip end to end: open a
|
|
//! file through the `runtime` file API, write to it, seek back, read it, and compare.
|
|
//! On success it heartbeats "vfstest: ok" so the kernel test can observe it;
|
|
//! on failure it reports what went wrong. Shipped in the initial_ramdisk alongside vfs.
|
|
|
|
const std = @import("std");
|
|
const runtime = @import("runtime");
|
|
|
|
pub fn main() void {
|
|
const u = @import("posix").unistd;
|
|
const payload = "hello-vfs";
|
|
|
|
// The VFS server may not have registered yet — retry open until it's up.
|
|
var fd: i32 = -1;
|
|
var tries: u32 = 0;
|
|
while (fd < 0 and tries < 200) : (tries += 1) {
|
|
fd = u.open("greeting", u.O_CREAT);
|
|
if (fd < 0) runtime.system.sleep(20);
|
|
}
|
|
if (fd < 0) {
|
|
_ = runtime.system.write("vfstest: open failed\n");
|
|
return;
|
|
}
|
|
|
|
if (u.write(fd, payload) != @as(isize, payload.len)) {
|
|
_ = runtime.system.write("vfstest: write failed\n");
|
|
return;
|
|
}
|
|
_ = u.lseek(fd, 0, u.SEEK_SET);
|
|
|
|
var buffer: [32]u8 = undefined;
|
|
const n = u.read(fd, &buffer);
|
|
u.close(fd);
|
|
|
|
if (n == @as(isize, payload.len) and std.mem.eql(u8, buffer[0..@intCast(n)], payload)) {
|
|
while (true) {
|
|
_ = runtime.system.write("vfstest: ok\n");
|
|
runtime.system.sleep(1000);
|
|
}
|
|
}
|
|
_ = runtime.system.write("vfstest: mismatch\n");
|
|
}
|
|
|
|
pub const panic = runtime.panic;
|
|
comptime {
|
|
_ = &runtime.start._start;
|
|
}
|