Blob


1 .TH INTRO 1
2 .SH NAME
3 intro \- introduction to Plan 9 from User Space
4 .SH DESCRIPTION
5 Plan 9 is a distributed computing environment built
6 at Bell Labs starting in the late 1980s.
7 The system can be obtained from Bell Labs at
8 .B http://plan9.bell-labs.com/plan9
9 and runs on PCs and a variety of other platforms.
10 Plan 9 became a convenient platform for experimenting
11 with new ideas, applications, and services.
12 .PP
13 Plan 9 from User Space provides many of the ideas,
14 applications, and services from Plan 9
15 on Unix-like systems.
16 It runs on
17 FreeBSD (x86),
18 Linux (x86 and PowerPC),
19 Mac OS X (PowerPC),
20 OpenBSD (x86),
21 and
22 SunOS (Sparc).
23 .SS Commands
24 Plan 9 from User Space expects its own directory tree,
25 conventionally
26 .BR /usr/local/plan9 .
27 When programs need to access files in the tree,
28 they expect the
29 .B $PLAN9
30 environment variable
31 to contain the name of the root of the tree.
32 See
33 .IR install (1)
34 for details about installation.
35 .PP
36 Many of the familiar Unix commands,
37 for example
38 .IR cat (1),
39 .IR ls (1),
40 and
41 .IR wc (1),
42 are present, but in their Plan 9 forms:
43 .I cat
44 takes no options,
45 .I ls
46 does not columnate its output when printing to a terminal,
47 and
48 .I wc
49 counts UTF characters.
50 In some cases, the differences are quite noticeable:
51 .IR grep (1)
52 and
53 .IR sed (1)
54 expect Plan 9 regular expressions
55 (see
56 .IR regexp (7)),
57 which are closest to what Unix calls extended regular expressions.
58 Because of these differences, it is not recommended to put
59 .B $PLAN9/bin
60 before the usual system
61 .B bin
62 directories in your search path.
63 Instead, put it at the end of your path and use the
64 .IR 9 (1)
65 script when you want to invoke the Plan 9 version of a
66 traditional Unix command.
67 .PP
68 Occasionally the Plan 9 programs have been
69 changed to adapt to Unix.
70 .IR Mk (1)
71 now allows mkfiles to choose their own shell,
72 and
73 .IR rc (1)
74 has a
75 .I ulimit
76 builtin and manages
77 .BR $PATH .
78 .PP
79 Many of the graphical programs from Plan 9 are present,
80 including
81 .IR sam (1)
82 and
83 .IR acme (1).
84 An X11 window manager
85 .IR rio (1)
86 mimics Plan 9's window system, with command windows
87 implemented by the external program
88 .IR 9term (1).
89 Following the style of X Windows, these programs run in new
90 windows rather than the one in which they are invoked.
91 They all take a
92 .B -W
93 option to specify the size and placement of the new window.
94 The argument is one of
95 \fIwidth\^\^\fLx\fI\^\^height\fR,
96 \fIwidth\^\^\fLx\fI\^\^height\^\^\fL@\fI\^\^xmin\fL,\fIxmax\fR,
97 \fL'\fIxmin ymin xmax ymax\fL'\fR,
98 \fRor
99 \fIxmin\fL,\fIymin\fL,\fIxmax\fL,\fIymax\fR.
100 .PP
101 The
102 .IR plumber (4)
103 helps to connect the various Plan 9 programs together,
104 and fittings like
105 .IR web (1)
106 connect it to external programs such as web browsers;
107 one can click on a URL in
108 .I acme
109 and see the page load in
110 .IR Firefox .
111 .SS User-level file servers
112 In Plan 9, user-level file servers present file trees via the Plan 9 file protocol, 9P.
113 Processes can mount arbitrary file servers and customize their own name spaces.
114 These facilities are used to connect programs. Clients interact
115 with file servers by reading and writing files.
116 .PP
117 This cannot be done directly on Unix.
118 Instead the servers listen for 9P connections on Unix domain sockets;
119 clients connect to these sockets and speak 9P directly using the
120 .IR 9pclient (3)
121 library.
122 .IR Intro (4)
123 tells more of the story.
124 The effect is not as clean as on Plan 9, but it gets the job done
125 and still provides a uniform and easy-to-understand mechanism.
126 The
127 .IR 9p (1)
128 client can be used in shell scripts or by hand to carry out
129 simple interactions with servers.
130 .SS External databases
131 Some programs rely on large databases that would be
132 cumbersome to include in every release.
133 Scripts are provided that download these databases separately.
134 These databases can be downloaded separately.
135 See
136 .B $PLAN9/dict/README
137 and
138 .BR $PLAN9/sky/README .
139 .SS Programming
140 The shell scripts
141 .I 9c
142 and
143 .I 9l
144 (see
145 .IR 9c (1))
146 provide a simple interface to the underlying system compiler and linker,
147 similar to the
148 .I 2c
149 and
150 .I 2l
151 families on Plan 9.
152 .I 9c
153 compiles source files, and
154 .I 9l
155 links object files into executables.
156 When using Plan 9 libraries,
157 .I 9l
158 infers the correct set of libraries from the object files,
159 so that no
160 .B -l
161 options are needed.
162 .PP
163 The only way to write multithreaded programs is to use the
164 .IR thread (3)
165 library.
166 .IR Rfork (3)
167 exists but is not as capable as on Plan 9.
168 There are many unfortunate by necessary preprocessor
169 diversions to make Plan 9 and Unix libraries coexist.
170 See
171 .IR intro (3)
172 for details.
173 .PP
174 The debuggers
175 .IR acid (1)
176 and
177 .IR db (1)
178 and the debugging library
179 .IR mach (3)
180 are works in progress.
181 They are platform-independent, so that x86 Linux core dumps
182 can be inspected on PowerPC Mac OS X machines,
183 but they are also fairly incomplete.
184 The x86 target is the most mature; initial PowerPC support
185 exists; and other targets are unimplemented.
186 The debuggers can only inspect, not manipulate, target processes.
187 Support for operating system threads and for 64-bit architectures
188 needs to be rethought.
189 On x86 Linux systems,
190 .I acid
191 and
192 .I db
193 can be relied upon to produce reasonable stack traces
194 (often in cases when GNU
195 .I gdb
196 cannot)
197 and dump data structures,
198 but that it is the extent to which they have been developed and exercised.
199 .SS Porting programs
200 The vast majority of the familiar Plan 9 programs
201 have been ported, including the Unicode-aware
202 .IR troff (1).
203 .PP
204 Of the more recent additions to Plan 9,
205 the
206 .IR secstore (1)
207 client has been ported, though
208 .I secstored
209 has not.
210 .IR Vac (1)
211 and
212 .IR vacfs (4)
213 have been ported.
214 .IR Factotum
215 and
216 .IR venti
217 are in progress.
218 .PP
219 A backup system providing a dump file system built atop Venti
220 is also in progress.
221 .SS Porting to new systems
222 Porting the tree to new operating systems or architectures
223 should be straightforward, as system-specific code has been
224 kept to a minimum.
225 The largest pieces of system-specific code are
226 .BR <u.h> ,
227 which must include the right system files and
228 set up the right integer type definitions,
229 and
230 .IR libthread ,
231 which must implement spin locks, operating system thread
232 creation, and context switching routines.
233 Portable implementations of these using
234 .B <pthread.h>
235 and
236 .B <ucontext.h>
237 already exist. If your system supports them, you may not
238 need to write any system specific code at all.
239 .PP
240 There are other smaller system dependencies,
241 such as the terminal handling code in
242 .IR 9term (1)
243 and the implementation of
244 .IR getcallerpc (3),
245 but these are usually simple and are not on the critical
246 path for getting the system up and running.
247 .SH SEE ALSO
248 The rest of this manual describes Plan 9 from User Space.
249 Many of the man pages have been brought from Plan 9,
250 but they have been updated, and others have been written from scratch.
251 .PP
252 The manual pages are in a Unix style tree, with names like
253 .B $PLAN9/man/man1/cat.1
254 instead of Plan 9's simpler
255 .BR $PLAN9/man/1/cat ,
256 so that the Unix
257 .IR man (1)
258 utility can handle it.
259 Some systems, for example Debian Linux,
260 deduce the man page locations from the search path, so that
261 adding
262 .B $PLAN9/bin
263 to your path is sufficient to cause
264 .B $PLAN9/man
265 to be consulted for manual pages using the system
266 .IR man .
267 On other systems, or to look at manual pages with the
268 same name as a system page,
269 invoke the Plan 9
270 .I man
271 directly, as in
272 .B 9
273 .B man
274 .BR cat .
275 .PP
276 The manual sections follow the Unix numbering conventions,
277 not the Plan 9 ones.
278 .PP
279 .HR ../man1 "Section (1)
280 describes general publicly accessible commands.
281 .PP
282 .HR ../man3 "Section (3)
283 describes C library functions.
284 .PP
285 .HR ../man4 "Section (4)
286 describes user-level file servers.
287 .PP
288 .HR ../man7 "Section (7)
289 describes file formats and protocols.
290 (On Unix, section (5) is technically for file formats but
291 seems now to be used for describing specific files.)
292 .\" .PP
293 .\" Section (8) describes commands used for system administration.
294 .PP
295 .HR ../man9 "Section (9p)
296 describes the Plan 9 file protocol 9P.
297 .PP
298 These pages describe parts of the system
299 that are new or different from Plan 9 from Bell Labs:
300 .IP
301 .IR 9 (1),
302 .IR 9c (1),
303 .IR 9p (1),
304 .IR 9term (1),
305 .I acidtypes
306 in
307 .IR acid (1),
308 .IR cvs (1),
309 .IR dial (1),
310 .IR label (1),
311 the
312 .B MKSHELL
313 variable in
314 .IR mk (1),
315 .IR namespace (1),
316 .IR page (1),
317 .IR psfonts (1),
318 .IR rio (1),
319 .IR web (1),
320 .IR wintext (1)
321 .IP
322 .IR intro (3),
323 .IR 9pclient (3),
324 the
325 .B unix
326 network in
327 .IR dial (3),
328 .IR exits (3),
329 .IR get9root (3),
330 .IR getns (3),
331 .IR notify (3),
332 .IR post9pservice (3),
333 .IR rfork (3),
334 .IR searchpath (3),
335 .IR sendfd (3),
336 .IR udpread (3),
337 .IR wait (3),
338 .IR wctl (3)
339 .IP
340 .IR intro (4),
341 .IR 9pserve (4),
342 .IR import (4)
343 .IP
344 .IR openfd (9p)
345 .SH DIAGNOSTICS
346 In Plan 9, a program's exit status is an arbitrary text string,
347 while on Unix it is an integer.
348 Section (1) of this manual describes commands as though they
349 exit with string statuses. In fact, exiting with an empty status
350 corresponds to exiting with status 0,
351 and exiting with any non-empty string corresponds to exiting with status 1.
352 See
353 .IR exits (3).