How 9fans/plan9port works
Purpose and entry points
Plan 9 from User Space (plan9port) ports Plan 9 libraries, commands, protocols, and desktop tools to Unix hosts. Installation starts at ./INSTALL, with top-level build orchestration in Makefile and configure; it first bootstraps the Plan 9-style mk build tool, then builds the rest. User-facing launchers and compatibility commands are installed from bin/.
Build and portability layer
The repository supports Unix-family platforms through per-OS make fragments and C adaptation layers. The native Unix build path is represented by unix/make/Makefile.all, unix/make/Makefile.CMD, and OS files such as unix/make/Make.Linux. The internal mk implementation is a primary bootstrap/runtime dependency: src/cmd/mk/main.c, src/cmd/mk/graph.c, src/cmd/mk/job.c. Project-specific source-build scripts are centralized under src/mkfile, src/mkmk.sh, and src/mkcommon.
Core compatibility libraries
Most programs target Plan 9 interfaces rather than direct Unix APIs. src/lib9/ supplies the base runtime—process, filesystem, networking, error, formatting, and UTF behavior—anchored by src/lib9/mkfile, src/lib9/main.c, and src/lib9/rfork.c. Common API contracts are exposed through include/libc.h, include/u.h, and include/utf.h. Higher-level reusable libraries provide buffered I/O (src/libbio/), cooperative threading (src/libthread/), regular expressions (src/libregexp/), cryptography (src/libsec/), and IP utilities (src/libip/).
9P namespace and service boundary
9P is the central remote-filesystem/service protocol boundary. Server-side primitives live in src/lib9p/srv.c, src/lib9p/fid.c, and src/lib9p/req.c; client-side filesystem operations live in src/lib9pclient/fs.c, src/lib9pclient/walk.c, and src/lib9pclient/auth.c. Commands such as src/cmd/9p.c, src/cmd/9pserve.c, and src/cmd/9pfuse/main.c expose, inspect, or bridge 9P services to Unix/FUSE environments.
Graphics, windows, and interactive tools
The draw stack separates client graphics APIs from host display backends. src/libdraw/drawclient.c, src/libdraw/window.c, and src/libmemdraw/draw.c implement drawing and in-memory rendering; src/cmd/devdraw/devdraw.c bridges to macOS/X11 backends. Interactive applications build above this boundary: the Rio window system (src/cmd/rio/main.c, src/cmd/rio/manage.c), Acme editor (src/cmd/acme/acme.c, src/cmd/acme/fsys.c), Sam editor (src/cmd/sam/sam.c), and 9term terminal (src/cmd/9term/9term.c).
System services and persistent storage
Several substantial service implementations run as Unix processes while presenting Plan 9 interfaces. Fossil is a 9P archival filesystem with disk/cache logic (src/cmd/fossil/fossil.c, src/cmd/fossil/9p.c, src/cmd/fossil/fs.c). Venti is content-addressed block storage, split between client library (src/libventi/client.c, src/libventi/rpc.c) and server arena/index management (src/cmd/venti/srv/venti.c, src/cmd/venti/srv/arena.c, src/cmd/venti/srv/index.c). VAC and backup tools connect filesystem snapshots to Venti (src/cmd/vac/vac.c, src/cmd/vbackup/vbackup.c).
Network, authentication, and messaging
The distribution includes network-facing Unix services and clients: DNS/NDB (src/cmd/ndb/dnserver.c, src/libndb/dnsquery.c), authentication/key-agent functionality (src/cmd/auth/factotum/main.c, src/libauth/auth_rpc.c), and UPAS mail transport/storage (src/cmd/upas/smtp/smtpd.c, src/cmd/upas/send/main.c, src/cmd/upas/fs/fs.c). These components use external network services such as DNS, SMTP/IMAP/POP, SSH-compatible authentication, and 9P peers.
Distribution assets and command ecosystem
src/cmd/ is the broad command suite: Unix/Plan 9 shell and text tools, compilers/interpreters, document processing, image conversion, networking, and service daemons. Runtime resources are shipped beside binaries: fonts in font/, troff definitions in troff/ and postscript/, plumbing rules in plumb/, namespace/network data in ndb/, and executable wrappers in bin/. Man pages in man/ describe the installed interface; packaging/release assembly is under dist/.
Main entry points: Makefile Top-level build · fs.c 9P client library · drawclient.c Draw stack · Makefile.all Unix build rules
Components 24
Build & Portability
- Installation · Bootstraps mk before building the distribution.
- Top-level build
Makefile - Unix build rules · Selects per-OS compilation and command build rules.
unix/make/Makefile.all - mk · Bootstrapped build executor used for project sources.
src/cmd/mk/main.c - Source build scripts
src/mkfile
Compatibility Runtime
- Plan 9 API headers
include/libc.h - lib9 · Adapts Plan 9 process, filesystem, network, error, and UTF interfaces to Unix.
- Support libraries · Buffered I/O, threads, regex, crypto, and IP utilities.
Protocol & Services
- 9P server library
src/lib9p/srv.c - 9P client library
src/lib9pclient/fs.c - 9P commands & FUSE · Exposes, inspects, and mounts 9P services on Unix.
src/cmd/9pfuse/main.c - Fossil · Persistent filesystem with disk and cache management.
src/cmd/fossil/fossil.c - Venti · Block storage server with arena and index management.
src/cmd/venti/srv/venti.c - VAC & backup
src/cmd/vac/vac.c - Network services · DNS/NDB, factotum authentication, and UPAS mail services.
src/cmd/ndb/dnserver.c
Desktop Stack
- Draw stack · Client drawing APIs and in-memory rendering.
src/libdraw/drawclient.c - devdraw · Connects draw clients to macOS and X11 backends.
src/cmd/devdraw/devdraw.c - Interactive applications
src/cmd/rio/main.c
Distribution
- Command suite · Broad collection of shell, text, compiler, document, image, network, and daemon tools.
- Installed launchers
- Runtime assets · Fonts, troff resources, plumbing rules, and namespace/network data.
- Manual interface
- Release assembly
Other components
- External peers · Unix display systems plus DNS, mail, authentication, and 9P endpoints.
Connections 24
- Installation → Top-level build: starts
- Top-level build → mk: bootstraps
- Top-level build → Unix build rules: uses
- mk → Source build scripts: executes
- Source build scripts → Command suite: builds
- Unix build rules → lib9: builds for host
- Plan 9 API headers → lib9: defines APIs
- lib9 → Support libraries: underpins
- Support libraries → 9P server library: supports
- Support libraries → 9P client library: supports
- 9P client library → 9P commands & FUSE: used by
- 9P server library → Fossil: serves through
- 9P client library → Fossil: accesses
- VAC & backup → Venti: stores snapshots in
- Command suite → Network services: includes
- Network services → External peers: connects to
- Draw stack → devdraw: renders through
- devdraw → External peers: uses display backend
- Draw stack → Interactive applications: renders
- Command suite → Interactive applications: includes
- Command suite → Installed launchers: installed via
- Runtime assets → Command suite: runtime resources
- Release assembly → Installed launchers: assembles
- Manual interface → Installed launchers: documents