PathrockNetwork Gno Explorer
HomeBlocksTransactionsTokensRealmsPackagesValidatorsAnalytics

PathrockNetwork Gno Explorer — an independent explorer for Gno.land Mainnet (gnoland-1), operated by PathrockNetwork. Not an official Gno.land service.

gnowebarchive RPC

gno.land/p/moul/x/plan9/memfs/v0

Package
Open in gnoweb ↗

Overview

Kind
Pure package
Name
v0
Namespace
moul / x / plan9 / memfs
Files
4 (README)(gnomod.toml)
Exported functions
n/a — not supported for pure packages by the node (vm/qfuncs)
Module
gno.land/p/moul/x/plan9/memfs/v0
gno
0.9

Files (4)

  • README.mdmarkdown
  • gnomod.tomltoml
  • memfs.gnogno
  • memfs_test.gnogno
README.mdPreviewRaw
# `gno.land/p/moul/x/plan9/memfs/v0`

**A RAM file server**: Plan 9's `ramfs`, in a realm's heap. The reference
implementation of [`ninep.File`](../../ninep/v0) and `ninep.Mutable`.

```go
import memfs "gno.land/p/moul/x/plan9/memfs/v0"

fs := memfs.New("g1...", runtime.ChainHeight())
fs.MkdirAll("/usr/glenda/bin", height)
fs.WriteFile("/tmp/greeting", "hello\n", height)
root := 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](https://github.com/moul/gno-contracts/issues/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](https://p9f.org).
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](../../../../../NOTICE.md).

<!-- BEGIN GNOCONTRACTS FOOTER (generated by `make readmes`; do not edit below) -->

---

Part of **[moul/gno-contracts](https://github.com/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/moul/x/plan9/memfs/v0 dependency graph](https://raw.githubusercontent.com/moul/gno-contracts/main/_assets/gno.land/p/moul/x/plan9/memfs/v0/deps.png)

> 🧪 **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](https://github.com/moul/gno-contracts/blob/main/DISCLAIMER.md).

<!-- END GNOCONTRACTS FOOTER -->

Functions

not supported for pure packages by the node (vm/qfuncs)

Signatures reconstructed verbatim from vm/qfuncs — interface params keep their inline definitions.