Skip to content Search Apps Documentation Source Content File Folder Download Copy Actions State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

Community realm. Read the code first. Community realm, deployed by its author. Read the code before you interact or send coins.

README.md

2.81 Kb · 64 lines

gno.land/p/nym-moultest123/x/plan9/memfs/v0

A RAM file server: Plan 9's ramfs, in a realm's heap. The reference implementation of ninep.File and ninep.Mutable.

1import memfs "gno.land/p/nym-moultest123/x/plan9/memfs/v0"
2
3fs := memfs.New("g1...", runtime.ChainHeight())
4fs.MkdirAll("/usr/glenda/bin", height)
5fs.WriteFile("/tmp/greeting", "hello\n", height)
6root := fs.Root()   // a ninep.File, mountable into any namespace

Children live in an avl.Tree, so a directory listing is ordered by name and therefore identical on every validating node. A map would make Render a consensus bug.

Mutable is in-realm only. A non-crossing method runs in the caller's frame, so a foreign realm calling Create or Write here would be mutating objects it does not own. The read half is safe from anywhere, which is exactly what makes a memfs tree mountable into somebody else's namespace: they get reads, and only its owner gets writes.

The clock is a parameter, not an import. Every mutation takes the block height from the caller rather than reading chain state itself, so the same tree runs in a plain unit test.

9P behaviours reproduced rather than approximated:

  • A directory reports Length 0, as 9P does.
  • Qid.Version increments on every write, so a client holding a qid can tell "same file, changed" from "different file" without reading it.
  • Writing past the end extends the file with NUL bytes.
  • DMAPPEND pins every write to the end, whatever offset was asked for.
  • Removing a non-empty directory is refused.

Design and analysis: moul/gno-contracts#136.


Not affiliated with Plan 9. Plan 9 from Bell Labs is the work of the Computing Science Research Center at Bell Labs; the name and the marks are theirs, and the copyright is held by the Plan 9 Foundation. This package borrows the vocabulary and none of the code: it is an independent homage, asking what that ecosystem's spirit looks like on a chain. Full attribution: NOTICE.


Part of moul/gno-contracts — moul's versioned gno.land contracts. See the repository for the full catalog, build/test tooling, and usage.

Dependency graph:

gno.land/p/nym-moultest123/x/plan9/memfs/v0 dependency graph

🧪 Highly experimental — potentially vibe-coded. Not audited; may break, change, or be removed at any time. Do not use with anything of value. Full disclaimer: DISCLAIMER.