Files
bare-operating-system/packages/bare-os-booter/lib/bare-os-mounts-persist.js
T
Raven Scott 346bb71ffe Complete the internal “100 task” roadmap: coreutils and shell parity (xargs,
sh, diff/patch, sort, printf, find, test, getfacl/setfacl/xattr), expanded
/proc and metrics (process table, syscalls, replication, net, security
posture, worker budget, swarm/replication hints), initd DAG supervision
metadata and richer restart journal telemetry, synthetic process groups via
IPC (assignProcessGroup/signalProcessGroup) mirrored into process_table,
optional kernel.ext.d incremental hot reload (BARE_OS_KERNEL_EXT_D_HOT_RELOAD)
with reload audit NDJSON, features proc for hyperblobs dedup and systemd
subset documentation, vault threat model doc plus posture fields for AEAD,
Pear enclave pointer, account rotation continuity, and Ed25519 consistency
across boot manifest / extensions / replication. Adds or extends tests and
keeps kernel/ and packages/bare-os-seeder/kernel/ in parity; guest init is
bundled from kernel/lib/init/init-main.js via bundle-kernel-init.
2026-04-04 21:23:49 -04:00

54 lines
1.7 KiB
JavaScript

/**
* Persist an operator-facing snapshot of HDMS mounts on the system drive.
* Source of truth remains `/.bare/hdms/registry.json` on the personal drive.
*/
import b4a from 'b4a'
/**
* @param {{ writeFile?: Function, mkdir?: Function } | null | undefined} vfs
* @param {import('./hdms-manager.js').HdmsController | null | undefined} hdms
*/
export async function persistBareOsMountsSnapshot(vfs, hdms) {
if (!vfs || typeof vfs.writeFile !== 'function') return
if (!hdms?.active || !hdms.registry) return
/** @type {{ label: string, target: string, mode: string, readOnly: boolean, key?: string, ns?: string }[]} */
const mounts = []
for (const d of hdms.registry.drives) {
mounts.push({
label: d.label,
target: `/mnt/${d.label}`,
mode: d.mode,
readOnly: d.mode === 'readonly',
...(d.key ? { key: d.key } : {}),
...(d.ns ? { ns: d.ns } : {})
})
}
const doc = {
schemaVersion: 1,
updatedAt: new Date().toISOString(),
note: 'Snapshot for operators; authoritative registry is /.bare/hdms/registry.json on the personal drive. When writable, the same JSON is mirrored at /.bare/os/mounts_last.json for multi-drive tooling.',
mounts
}
const body = JSON.stringify(doc, null, 2) + '\n'
const buf = b4a.from(body, 'utf8')
try {
await vfs.mkdir('/etc/bare-os', { recursive: true })
} catch {
/* exists or pseudo */
}
try {
await vfs.writeFile('/etc/bare-os/mounts.json', buf)
} catch (e) {
console.warn('[bare-os] mounts.json persist failed:', e?.message || e)
}
try {
await vfs.mkdir('/.bare/os', { recursive: true })
await vfs.writeFile('/.bare/os/mounts_last.json', buf)
} catch {
/* personal tree may be unavailable in minimal tests */
}
}