Plan 9 at ADFA
Christopher Vance
School of Computer Science, UNSW
Australian Defence Force Academy
Canberra ACT 2600
Christopher.Vance@adfa.oz.au
14 February 1996
Overview of this talk
- introduction to the ideas and distinctives of Plan 9
- similarities to and differences from Unix
- demonstration of some of the more impressive bits of the system
- discussion of what I've been doing at ADFA, including future plans
- how to get it, how to get help
Introduction
- "build a Unix out of a lot of little systems, not a system out of a lot of little
Unixes"
- 9P file server protocol for network-level file access
- naming systems for customised view of resources
- new compiler for C, new language Alef, new shell rc, new libraries and window
systems, new applications
- many old tools dropped
- attempt to solve problems in the right places-tty driver is in window system, not
in kernel
- caters for ANSI/POSIX backwater
Compatibility
- default environment is not ANSI or POSIX-APE provides what compatibility is
possible
- many similarities to Unix, but many differences
- compilers, header files, libraries and commands are different
Design Features
- resources named and accessed as files using 9P, including /proc
- 9P controls file systems, not just blocks
- 9P is not extensible-even when used for kernel devices, only standard file
operations are possible
- namespace is private to process
Command Level
- use 8= for multiple windows
- program takes over current window, rather than starting a new one, so
networking already done
- many commands similar to Unix, but some are differently implemented (who is a
rc script, ps is 95 lines of C)
- use sam (or acme) instead of vi
- use rc (or, if desperate, ape/psh) instead of sh
- debugger acid
A Plan 9 System
- three kinds of machines
- terminals have no permanent files and are theoretically equivalent
- log in and own it, but not trusted without authentication-need to reboot between
logins
- file servers serve permanent files, but have no user processes-even system
processes only for file service
- cpu servers allow faster execution or more connectivity-may have multiple
users-behaves for each user as a faster terminal-server owns resources
- access to cpu servers only from terminals or other cpu servers-password from
terminal used with authentication server-no cleartext on network-alternative is
challenge-response
- access to file server only from terminals or cpu servers-allow NFS only with
challenge-response
Configuration and Administration
- terminals are identical-have no permanent files
- used for interactive work like editors
- cpu servers and file servers are centrally administered
- cpu servers used for cpu-intensive work
- bind in lib/profile imports terminal files (/dev/cons, etc.) to cpu server
- speed the only visible difference between terminal and cpu server
File Server Machines
- separate kernel with no user processes
- multilevel storage: at AT&T, 350G on WORM, 27G on disk, 100M in
memory-total of 40G active, so disk is only a cache
- no separate backup, just /n/dump/1996/0214, no source control, no df, no "please
clean up"
- in 5 years with 50 users, have used 65% of storage-an upgrade to current media
would leave more free than originally empty
- remote permission matching is done using user and group names, not
numbers-uid, gid relevant only within a single machine
- file servers use bilateral authentication
Device Servers and Streams
- these have ctl and data files, some also status, etc.
- many kernel services offered through devices
- net devices have clone file
- same protocol as normal file servers
Unusual File Servers
- /dev/pid, /dev/time, /dev/user, /dev/sysname, /dev/snarf, /dev/mouse, /env, /proc,
/fd, /net
- proc has text, ctl, status, note-remote mounting allows remote debugging, even
from a different architecture
- 8=
- multiplexes /dev/cons, /dev/mouse, /dev/bitblt
- can operate recursively (serving own environment)
- can edit all waiting input
- can toggle wait and edit (for mail, etc.)
- Unicode, fonts
- ftpfs (no ftp command), tapefs, ramfs
- exportfs serves part of own namespace-import to use-cpu for opposite
Compilers, Languages, Programming
- most stuff written in C
- requires prototypes
- handles Unicode
- not ANSI-#ifdef not #if, anonymous aggregates, aggregate displays-use ape,
pcc if necessary (ghostview)
- Bio replaces stdio in normal use
- header/library relationships are more intelligent
- unusual split between compiler and loader (both C and alef)
- some kernel and library in assembler
- assembler not often used
- still use lex, yacc
- some applications in alef, rc
- new rc, alef, mk
Portability
- heterogeneous
- cputype-what is executing, objtype-what to compile for
- all compilers are cross-compilers-if $cputype = $objtype, it's only a
coincidence
- each architecture has a character (v mips, k sparc, 8 386, 2 68020, x 3210, 6 960,
z hobbit)
- mips executable is v.out, object is *.v, compilers vc and val, loader vl, assembler
va, interpreter vi
- small volume IPC and device control/status files use text
- device control done with text commands to ctl file, no ioctl
- larger volume IPC use binary with fixed byte order (like compiler)
- ps is merely a reformatting of cat /proc/*/status
Parallelism
- alef is first choice (not 68020)-used in acme, httpd, ppp, page
- alef uses fine-grained fork sharing all resources (like a kernel thread-stack
always separate, though)
- rfork allows creation of processes or modification of invoking process to share,
copy, or create anew-environment, namespace, note group, fd table group,
memory
- rfork used many different ways, so appears to be the right abstraction
- memory shared using rfork or segattach
- rendezvous for exchanging values
- spinlocks on multiprocessors
Namespaces
- each process has a namespace which may be shared with other processes, but in
general is not
- bind, mount, unmount
- union directories mean PATH is obsolete
- private to process
- # as bootstrap namespace marker-#c console, #I IP, #S SCSI
- kernel devices directly accessible
- control devices by writing text messages to /ctl file
- same for /net/tcp, etc.-connect, announce, etc.
- mount driver translate procedure calls into 9P messages-sole RPC mechanism
Internet Link protocol
- reliable, ordered datagrams-connection-based
- TCP doesn't preserve message boundaries
- UDP not reliable, not ordered
Authentication
- DES and mutual challenge-response
- no cleartext keys (passwd doesn't run on cpu servers, only terminals)
- cpu server and file server use NV RAM for machine password, terminal requires
user to type own password
- authentication server knows all keys and participates in exchange
- similar to Kerberos but no synchronisation of clocks, does implement "speaks
for"
- authentication used in the protocol, not just relying on firewalls
Special users
- no superuser, but person on a terminal owns all terminal resources
- cpu & file servers have passwords, but require console access (fs console doesn't
breach or ignore file permissions)
- none-no password, can't access dump, can only access world-readable files
File Permissions
- user and group in same file, /adm/users
- passwords in auth server
Networking
- built in to Plan 9-terminal, cpu server, file server are different machines
- can use con, telnet, and rx to get to Unix or Plan 9 machines
- can use cpu to get to Plan 9 machines
- can use 9fs to get to Plan 9 file system on u9fs server or on Plan 9 file server
- cpu server can be destination of ftp, rlogin, and telnet from but require
challenge/response
- 25KLOC out of 50KLOC for a fully configured kernel
- /n/a:, /n/c: allow access to MSDOS file systems
Similarities to Unix
- most Plan 9 system calls similar to Unix
- many Plan 9 commands similar to Unix
- many Unix system calls missing
- some Unix commands missing
- fds, open, close, read, etc.
- hierarchical file system
- device tables
- basic commands and command syntax
- lp, mail
Differences from Unix
- in the file system, have regular files and directories-files may be marked
append-only or exclusive locking as part of mode
- interpretation of file or directory as device or service, or an aspect of these, is
done by the relevant file or kernel server from which that part of the namespace
is mounted-following mounts is done using the walk (or clwalk) element of 9P,
the file protocol
- effectively, the interpretation of a device is done by the way you got to it by
following the path to get to it, not merely by finding a specially marked file at the
end, as in Unix
- no links or symbolic links
- no inodes
- no setuid/setgid, no special users
- wstat replaces chmod, etc.
- file name path element is up to 28 characters with no unprintable characters
- reboot a terminal to log in
- bitmapped terminals
- 8=
- rc, not sh
- create with a final "e"
- mk, not make
- compilers, assemblers
- sam-split between display and editing
- no uucp
Significant Points of Plan 9
- file systems for many resources
- private name spaces
Discussion
- conventional monolithic kernel
- 9P not extensible
- suggest replacing streams with static queues
- fs code is distinct, requiring too much duplication of drivers
- can't describe namespace-cpu reinterprets lib/profile
ADFA
- installed 1993 version on standalone PC
- installed 1995 floppy version on networked PC
- installed u9fs with complete readonly CD-ROM images
- modified u9fs for readonly use, for unknown user, for user invocation
- new u9fsstart
- readonly installation of floppy system for general use
- floppy boot
- installing fs on SS2, cpu/auth on SS1+
Plans
- get TCP based auth server
- u9fs to do authentication
- DNS file system
- get other staff interested and using it
- use in teaching
Impressive Bits
- user interface is acme-mouse chords instead of typing-a nice user interface
(also wily)
- alef
- 8= is a nice window system
- much less frills than X and xterm-no icons
- rc is a nice shell (I've been using a reimplementation of it on Unix for a number
of years as my preferred shell)
- much simpler quoting
- control structures more like C
- sam is a nice editor (I used it for a while before buckling under with dumb
VT100 access)
- regular expressions may include parts of several lines
- more regular command language
- REs over file names
- same REs used everywhere in Plan 9 except for rc filename globbing
- debugger is acid-language, not just a command set
- demonstrate 8=, rc, sam, acme
- tools hosted on Unix-sam(term), u9fs, ilgate, rc, wily, 9term, 9wm, libXg
- clean, small OS
- most play is in writing device drivers or reimplementing typical tasks using new
tools (news reader)
- good fun
- nice to use
How do you get it
- most sources are supplied-not crypt, ksh, or C++
- ISBN 0-03-017143-1 (USD350) for 1 CD-ROM, 4 floppies, 2 books
- ISBN 0-03-017142-3 (USD125) for books only
- book 1 is manuals, book 2 is other documents, many (but not all) of which are
available elsewhere
- you could try H-B in Sydney-when I did, they didn't know about it
- Harcourt-Brace is +1 407 345 3800 (Orlando, Florida, timezone EST/EDT)
- may need to tell them you're in Australia, so they can check whether their local
distributor is supposed to have it
- choice of FedEx, airmail, slow
- shrink-wrap site licence for non-commercial use, AT&T will negotiate for
Commercial use
Help