aboutsummaryrefslogtreecommitdiff
path: root/man/man1/0intro.1
blob: 5c45aefe960cb389aeae6d538ab548b386265b7c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
.TH INTRO 1
.SH NAME
intro \- introduction to Plan 9 from User Space
.SH DESCRIPTION
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
.B http://9p.io/plan9
and runs on PCs and a variety of other platforms.
Plan 9 became a convenient platform for experimenting
with new ideas, applications, and services.
.PP
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),
and
SunOS (x86-64 and Sparc).
.SS Commands
Plan 9 from User Space expects its own directory tree,
conventionally
.BR /usr/local/plan9 .
When programs need to access files in the tree,
they expect the
.B $PLAN9
environment variable 
to contain the name of the root of the tree.
See
.IM install (1)
for details about installation.
.PP
Many of the familiar Unix commands,
for example
.IM cat (1) ,
.IM ls (1) ,
and
.IM 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,
and
.I wc
counts UTF characters.
In some cases, the differences are quite noticeable:
.IM grep (1)
and
.IM sed (1)
expect Plan 9 regular expressions
(see
.IM 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
.IM 9 (1)
script when you want to invoke the Plan 9 version of a
traditional Unix command.
.PP
Occasionally the Plan 9 programs have been
changed to adapt to Unix.
.IM Mk (1)
now allows mkfiles to choose their own shell,
and
.IM rc (1)
has a
.I ulimit
builtin and manages
.BR $PATH .
.PP
Many of the graphical programs from Plan 9 are present,
including
.IM sam (1)
and
.IM acme (1) .
An X11 window manager
.IM rio (1)
mimics Plan 9's window system, with command windows
implemented by the external program
.IM 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
\fIwidth\^\^\fLx\fI\^\^height\fR,
\fIwidth\^\^\fLx\fI\^\^height\^\^\fL@\fI\^\^xmin\fL,\fIxmax\fR,
\fL'\fIxmin ymin xmax ymax\fL'\fR,
\fRor
\fIxmin\fL,\fIymin\fL,\fIxmax\fL,\fIymax\fR.
.PP
The
.IM plumber (4)
helps to connect the various Plan 9 programs together,
and fittings like
.IM 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.
.PP
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
.IM 9pclient (3)
library.
.IM 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.
The
.IM 9p (1)
client can be used in shell scripts or by hand to carry out
simple interactions with servers.
.IM 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.  
See
.B $PLAN9/dict/README
and
.BR $PLAN9/sky/README .
.SS Programming
The shell scripts
.I 9c
and
.I 9l
(see
.IM 9c (1) )
provide a simple interface to the underlying system compiler and linker,
similar to the 
.I 2c
and
.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.
.PP
The only way to write multithreaded programs is to use the
.IM thread (3)
library.
.IM 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.
See
.IM intro (3)
for details.
.PP
The debuggers
.IM acid (1)
and
.IM db (1)
and the debugging library
.IM 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
and
.I db
can be relied upon to produce reasonable stack traces
(often in cases when GNU
.I gdb
cannot)
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
.IM troff (1) .
.PP
Of the more recent additions to Plan 9,
.IM factotum (4) ,
.IM secstore (1) ,
and
.IM secstored (1) ,
.IM vac (1) ,
.IM vacfs (4) ,
and
.IM venti (8)
are all ported.
.PP
A backup system providing a dump file system built atop Venti
is in progress; see
.IM 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,
and
.IR libthread ,
which must implement spin locks, operating system thread
creation, and context switching routines.
Portable implementations of these using 
.B <pthread.h>
and
.B <ucontext.h>
already exist.  If your system supports them, you may not
need to write any system specific code at all.
.PP
There are other smaller system dependencies,
such as the terminal handling code in
.IM 9term (1)
and the implementation of
.IM getcallerpc (3) ,
but these are usually simple and are not on the critical
path for getting the system up and running.
.SH SEE ALSO
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.
.PP
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
.IM man (1)
utility can handle it.
Some systems, for example Debian Linux,
deduce the man page locations from the search path, so that
adding 
.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 .
.PP
The manual sections follow the Unix numbering conventions,
not the Plan 9 ones.
.PP
.HR ../man1 "Section (1)
describes general publicly accessible commands.
.PP
.HR ../man3 "Section (3)
describes C library functions.
.PP
.HR ../man4 "Section (4)
describes user-level file servers.
.PP
.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.)
.PP
.HR ../man8 "Section (8)
describes commands used for system administration.
.PP
.HR ../man9 "Section (9p)
describes the Plan 9 file protocol 9P.
.PP
These pages describe parts of the system
that are new or different from Plan 9 from Bell Labs:
.IP
.IM 9 (1) ,
.IM 9c (1) ,
.IM 9p (1) ,
.IM 9term (1) ,
.I acidtypes
in
.IM acid (1) ,
.IM dial (1) ,
.IM git (1) ,
.IM label (1) ,
the
.B MKSHELL
variable in
.IM mk (1) ,
.IM namespace (1) ,
.IM netfiles (1) ,
.IM page (1) ,
.IM psfonts (1) ,
.IM rio (1) ,
.IM web (1) ,
.IM wintext (1)
.IP
.IM intro (3) ,
.IM 9pclient (3) ,
the
.B unix
network in
.IM dial (3) ,
.IM exits (3) ,
.IM get9root (3) ,
.IM getns (3) ,
.IM notify (3) ,
.IM post9pservice (3) ,
.IM rfork (3) ,
.IM searchpath (3) ,
.IM sendfd (3) ,
.IM udpread (3) ,
.IM venti (3) ,
.IM wait (3) ,
.IM wctl (3)
.IP
.IM intro (4) ,
.IM 9pserve (4) ,
.IM import (4) ,
.IP
.IM vbackup (8)
.IP
.IR openfd (9p)
.SH DIAGNOSTICS
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.
See
.IM exits (3) .