blob: f018fc8a216dca5d92e1f3b31b08d6e06991d41a [file] [log] [blame]
intro \- introduction to Plan 9 from User Space
Plan 9 is a distributed computing environment built
at Bell Labs starting in the late 1980s.
The system can be obtained from Bell Labs at
and runs on PCs and a variety of other platforms.
Plan 9 became a convenient platform for experimenting
with new ideas, applications, and services.
Plan 9 from User Space provides many of the ideas,
applications, and services from Plan 9
on Unix-like systems.
It runs on
FreeBSD (x86, x86-64),
Linux (x86, x86-64, PowerPC and ARM),
Mac OS X (x86, x86-64, and PowerPC),
NetBSD (x86 and PowerPC),
OpenBSD (x86 and PowerPC),
Dragonfly BSD (x86-64),
SunOS (x86-64 and Sparc).
.SS Commands
Plan 9 from User Space expects its own directory tree,
.BR /usr/local/plan9 .
When programs need to access files in the tree,
they expect the
environment variable
to contain the name of the root of the tree.
.IR install (1)
for details about installation.
Many of the familiar Unix commands,
for example
.IR cat (1),
.IR ls (1),
.IR wc (1),
are present, but in their Plan 9 forms:
.I cat
takes no options,
.I ls
does not columnate its output when printing to a terminal,
.I wc
counts UTF characters.
In some cases, the differences are quite noticeable:
.IR grep (1)
.IR sed (1)
expect Plan 9 regular expressions
.IR regexp (7)),
which are closest to what Unix calls extended regular expressions.
Because of these differences, it is not recommended to put
.B $PLAN9/bin
before the usual system
.B bin
directories in your search path.
Instead, put it at the end of your path and use the
.IR 9 (1)
script when you want to invoke the Plan 9 version of a
traditional Unix command.
Occasionally the Plan 9 programs have been
changed to adapt to Unix.
.IR Mk (1)
now allows mkfiles to choose their own shell,
.IR rc (1)
has a
.I ulimit
builtin and manages
Many of the graphical programs from Plan 9 are present,
.IR sam (1)
.IR acme (1).
An X11 window manager
.IR rio (1)
mimics Plan 9's window system, with command windows
implemented by the external program
.IR 9term (1).
Following the style of X Windows, these programs run in new
windows rather than the one in which they are invoked.
They all take a
.B -W
option to specify the size and placement of the new window.
The argument is one of
\fL'\fIxmin ymin xmax ymax\fL'\fR,
.IR plumber (4)
helps to connect the various Plan 9 programs together,
and fittings like
.IR web (1)
connect it to external programs such as web browsers;
one can click on a URL in
.I acme
and see the page load in
.IR Firefox .
.SS User-level file servers
In Plan 9, user-level file servers present file trees via the Plan 9 file protocol, 9P.
Processes can mount arbitrary file servers and customize their own name spaces.
These facilities are used to connect programs. Clients interact
with file servers by reading and writing files.
This cannot be done directly on Unix.
Instead the servers listen for 9P connections on Unix domain sockets;
clients connect to these sockets and speak 9P directly using the
.IR 9pclient (3)
.IR Intro (4)
tells more of the story.
The effect is not as clean as on Plan 9, but it gets the job done
and still provides a uniform and easy-to-understand mechanism.
.IR 9p (1)
client can be used in shell scripts or by hand to carry out
simple interactions with servers.
.IR Netfiles (1)
is an experimental client for acme.
.SS External databases
Some programs rely on large databases that would be
cumbersome to include in every release.
Scripts are provided that download these databases separately.
These databases can be downloaded separately.
.SS Programming
The shell scripts
.I 9c
.I 9l
.IR 9c (1))
provide a simple interface to the underlying system compiler and linker,
similar to the
.I 2c
.I 2l
families on Plan 9.
.I 9c
compiles source files, and
.I 9l
links object files into executables.
When using Plan 9 libraries,
.I 9l
infers the correct set of libraries from the object files,
so that no
.B -l
options are needed.
The only way to write multithreaded programs is to use the
.IR thread (3)
.IR Rfork (3)
exists but is not as capable as on Plan 9.
There are many unfortunate by necessary preprocessor
diversions to make Plan 9 and Unix libraries coexist.
.IR intro (3)
for details.
The debuggers
.IR acid (1)
.IR db (1)
and the debugging library
.IR mach (3)
are works in progress.
They are platform-independent, so that x86 Linux core dumps
can be inspected on PowerPC Mac OS X machines,
but they are also fairly incomplete.
The x86 target is the most mature; initial PowerPC support
exists; and other targets are unimplemented.
The debuggers can only inspect, not manipulate, target processes.
Support for operating system threads and for 64-bit architectures
needs to be rethought.
On x86 Linux systems,
.I acid
.I db
can be relied upon to produce reasonable stack traces
(often in cases when GNU
.I gdb
and dump data structures,
but that it is the extent to which they have been developed and exercised.
.SS Porting programs
The vast majority of the familiar Plan 9 programs
have been ported, including the Unicode-aware
.IR troff (1).
Of the more recent additions to Plan 9,
.IR factotum (4),
.IR secstore (1),
.IR secstored (1),
.IR vac (1),
.IR vacfs (4),
.IR venti (8)
are all ported.
A backup system providing a dump file system built atop Venti
is in progress; see
.IR vbackup (8).
.SS Porting to new systems
Porting the tree to new operating systems or architectures
should be straightforward, as system-specific code has been
kept to a minimum.
The largest pieces of system-specific code are
.BR <u.h> ,
which must include the right system files and
set up the right integer type definitions,
.IR libthread ,
which must implement spin locks, operating system thread
creation, and context switching routines.
Portable implementations of these using
.B <pthread.h>
.B <ucontext.h>
already exist. If your system supports them, you may not
need to write any system specific code at all.
There are other smaller system dependencies,
such as the terminal handling code in
.IR 9term (1)
and the implementation of
.IR getcallerpc (3),
but these are usually simple and are not on the critical
path for getting the system up and running.
The rest of this manual describes Plan 9 from User Space.
Many of the man pages have been brought from Plan 9,
but they have been updated, and others have been written from scratch.
The manual pages are in a Unix style tree, with names like
.B $PLAN9/man/man1/cat.1
instead of Plan 9's simpler
.BR $PLAN9/man/1/cat ,
so that the Unix
.IR man (1)
utility can handle it.
Some systems, for example Debian Linux,
deduce the man page locations from the search path, so that
.B $PLAN9/bin
to your path is sufficient to cause
.B $PLAN9/man
to be consulted for manual pages using the system
.IR man .
On other systems, or to look at manual pages with the
same name as a system page,
invoke the Plan 9
.I man
directly, as in
.B 9
.B man
.BR cat .
The manual sections follow the Unix numbering conventions,
not the Plan 9 ones.
.HR ../man1 "Section (1)
describes general publicly accessible commands.
.HR ../man3 "Section (3)
describes C library functions.
.HR ../man4 "Section (4)
describes user-level file servers.
.HR ../man7 "Section (7)
describes file formats and protocols.
(On Unix, section (5) is technically for file formats but
seems now to be used for describing specific files.)
.HR ../man8 "Section (8)
describes commands used for system administration.
.HR ../man9 "Section (9p)
describes the Plan 9 file protocol 9P.
These pages describe parts of the system
that are new or different from Plan 9 from Bell Labs:
.IR 9 (1),
.IR 9c (1),
.IR 9p (1),
.IR 9term (1),
.I acidtypes
.IR acid (1),
.IR dial (1),
.IR git (1),
.IR label (1),
variable in
.IR mk (1),
.IR namespace (1),
.IR netfiles (1),
.IR page (1),
.IR psfonts (1),
.IR rio (1),
.IR web (1),
.IR wintext (1)
.IR intro (3),
.IR 9pclient (3),
.B unix
network in
.IR dial (3),
.IR exits (3),
.IR get9root (3),
.IR getns (3),
.IR notify (3),
.IR post9pservice (3),
.IR rfork (3),
.IR searchpath (3),
.IR sendfd (3),
.IR udpread (3),
.IR venti (3),
.IR wait (3),
.IR wctl (3)
.IR intro (4),
.IR 9pserve (4),
.IR import (4),
.IR vbackup (8)
.IR openfd (9p)
In Plan 9, a program's exit status is an arbitrary text string,
while on Unix it is an integer.
Section (1) of this manual describes commands as though they
exit with string statuses. In fact, exiting with an empty status
corresponds to exiting with status 0,
and exiting with any non-empty string corresponds to exiting with status 1.
.IR exits (3).