Skip to content

readonlyFS

readonlyFS(inner): Fileserver

Defined in: packages/core/src/kernel/fileservers/readonly.ts:56

Wrap a fileserver to reject all write operations with EPERM.

Fileserver

The underlying fileserver to expose read-only.

Fileserver

A Fileserver that delegates reads and rejects writes.

Plan 9 treats read-only as a mount flag, not a server property — the same backing server may be mounted RW in one namespace and RO in another. readonlyFS is the implementation of that flag: it forwards read, stat, readdir, and non-mutating open() calls to inner, and short-circuits write, mkdir, remove, rename, wstat, and any open() with write / create / truncate flags to EPERM.

The wrapper’s type field becomes "readonly(<inner.type>)" so /proc/mounts-style listings stay self-describing. inner is held by reference — mutations performed by other holders of the same reference are still visible to readers through this wrapper.

import { readonlyFS, memoryFS, Unix } from '@fishnet/core'
const base = memoryFS()
// share `base` with the rest of the system RW…
const sys = await Unix().mount('/snapshot', readonlyFS(base)).build().boot()
// …but `/snapshot` rejects any mutation.

Does NOT freeze inner — other code paths holding the same reference can still mutate it. Use memoryFS().freeze() when you need global immutability rather than a per-mount flag.