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 .IR factotum (4),
206 .IR secstore (1),
207 and
208 .IR secstored (1)
209 are all ported.
210 .IR Vac (1)
211 and
212 .IR vacfs (4)
213 have also been ported;
214 .IR venti
215 is in progress.
216 .PP
217 A backup system providing a dump file system built atop Venti
218 is in progress.
219 .SS Porting to new systems
220 Porting the tree to new operating systems or architectures
221 should be straightforward, as system-specific code has been
222 kept to a minimum.
223 The largest pieces of system-specific code are
224 .BR <u.h> ,
225 which must include the right system files and
226 set up the right integer type definitions,
227 and
228 .IR libthread ,
229 which must implement spin locks, operating system thread
230 creation, and context switching routines.
231 Portable implementations of these using
232 .B <pthread.h>
233 and
234 .B <ucontext.h>
235 already exist. If your system supports them, you may not
236 need to write any system specific code at all.
237 .PP
238 There are other smaller system dependencies,
239 such as the terminal handling code in
240 .IR 9term (1)
241 and the implementation of
242 .IR getcallerpc (3),
243 but these are usually simple and are not on the critical
244 path for getting the system up and running.
245 .SH SEE ALSO
246 The rest of this manual describes Plan 9 from User Space.
247 Many of the man pages have been brought from Plan 9,
248 but they have been updated, and others have been written from scratch.
249 .PP
250 The manual pages are in a Unix style tree, with names like
251 .B $PLAN9/man/man1/cat.1
252 instead of Plan 9's simpler
253 .BR $PLAN9/man/1/cat ,
254 so that the Unix
255 .IR man (1)
256 utility can handle it.
257 Some systems, for example Debian Linux,
258 deduce the man page locations from the search path, so that
259 adding
260 .B $PLAN9/bin
261 to your path is sufficient to cause
262 .B $PLAN9/man
263 to be consulted for manual pages using the system
264 .IR man .
265 On other systems, or to look at manual pages with the
266 same name as a system page,
267 invoke the Plan 9
268 .I man
269 directly, as in
270 .B 9
271 .B man
272 .BR cat .
273 .PP
274 The manual sections follow the Unix numbering conventions,
275 not the Plan 9 ones.
276 .PP
277 .HR ../man1 "Section (1)
278 describes general publicly accessible commands.
279 .PP
280 .HR ../man3 "Section (3)
281 describes C library functions.
282 .PP
283 .HR ../man4 "Section (4)
284 describes user-level file servers.
285 .PP
286 .HR ../man7 "Section (7)
287 describes file formats and protocols.
288 (On Unix, section (5) is technically for file formats but
289 seems now to be used for describing specific files.)
290 .\" .PP
291 .\" Section (8) describes commands used for system administration.
292 .PP
293 .HR ../man9 "Section (9p)
294 describes the Plan 9 file protocol 9P.
295 .PP
296 These pages describe parts of the system
297 that are new or different from Plan 9 from Bell Labs:
298 .IP
299 .IR 9 (1),
300 .IR 9c (1),
301 .IR 9p (1),
302 .IR 9term (1),
303 .I acidtypes
304 in
305 .IR acid (1),
306 .IR cvs (1),
307 .IR dial (1),
308 .IR label (1),
309 the
310 .B MKSHELL
311 variable in
312 .IR mk (1),
313 .IR namespace (1),
314 .IR page (1),
315 .IR psfonts (1),
316 .IR rio (1),
317 .IR web (1),
318 .IR wintext (1)
319 .IP
320 .IR intro (3),
321 .IR 9pclient (3),
322 the
323 .B unix
324 network in
325 .IR dial (3),
326 .IR exits (3),
327 .IR get9root (3),
328 .IR getns (3),
329 .IR notify (3),
330 .IR post9pservice (3),
331 .IR rfork (3),
332 .IR searchpath (3),
333 .IR sendfd (3),
334 .IR udpread (3),
335 .IR wait (3),
336 .IR wctl (3)
337 .IP
338 .IR intro (4),
339 .IR 9pserve (4),
340 .IR import (4)
341 .IP
342 .IR openfd (9p)
343 .SH DIAGNOSTICS
344 In Plan 9, a program's exit status is an arbitrary text string,
345 while on Unix it is an integer.
346 Section (1) of this manual describes commands as though they
347 exit with string statuses. In fact, exiting with an empty status
348 corresponds to exiting with status 0,
349 and exiting with any non-empty string corresponds to exiting with status 1.
350 See
351 .IR exits (3).