Subversion Repositories planix.SVN

Rev

Rev 2 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 - 1
.TH CONS 3
2
.SH NAME
3
cons \- console, clocks, process/process group ids, user, null, reboot, etc.
4
.SH SYNOPSIS
5
.nf
6
.B bind #c /dev
7
 
8
.B /dev/bintime
9
.B /dev/config
10
.B /dev/cons
11
.B /dev/consctl
12
.B /dev/cputime
13
.B /dev/drivers
14
.B /dev/hostdomain
15
.B /dev/hostowner
16
.B /dev/kmesg
17
.B /dev/kprint
18
.B /dev/null
19
.B /dev/osversion
20
.B /dev/pgrpid
21
.B /dev/pid
22
.B /dev/ppid
23
.B /dev/random
24
.B /dev/reboot
25
.B /dev/swap
26
.B /dev/sysname
27
.B /dev/sysstat
28
.B /dev/time
29
.B /dev/user
30
.B /dev/zero
31
.fi
32
.SH DESCRIPTION
33
The console device serves a one-level directory
34
giving access to the console and
35
miscellaneous information.
36
.PP
37
Reading the
38
.B cons
39
file returns characters typed on the keyboard.
40
Normally, characters are buffered to enable erase and kill processing.
41
A control-U,
42
.LR ^U ,
43
typed at the keyboard
44
.I kills
45
the current input line (removes all characters
46
from the buffer of characters
47
not yet read via
48
.BR cons ),
49
and a backspace
50
.I erases
51
the previous non-kill, non-erase character from the input buffer.
52
Killing and erasing only delete characters back to, but not including,
53
the last newline.
54
Characters typed at the keyboard actually produce 21-bit runes (see
55
.IR utf (6)),
56
but the runes are translated into the variable-length
57
.SM UTF
58
encoding (see
59
.IR utf (6))
60
before putting them into the buffer.
61
A
62
.IR read (2)
63
of length greater than zero causes the process to wait until a
64
newline or a
65
.L ^D
66
ends the buffer, and then returns as much of the buffer as the argument
67
to
68
.B read
69
allows, but only up to one complete line.
70
A terminating
71
.L ^D
72
is not put into the buffer.
73
If part of the line remains, the next
74
.B read
75
will return bytes from that remainder and not part of any new line
76
that has been typed since.
77
.PP
78
If
79
the string
80
.B rawon
81
has been written to the
82
.B consctl
83
file and the file is still open,
84
.B cons
85
is in
86
.IR "raw mode" :
87
characters are not echoed as they are typed,
88
backspace,
89
.L ^U
90
and
91
.L ^D
92
are not treated specially,
93
and characters are available to
94
.I read
95
as soon as they are typed.
96
Ordinary mode is reentered when
97
.B rawoff
98
is written to
99
.B consctl
100
or this file is closed.
101
.PP
102
A
103
.I write
104
(see
105
.IR read (2))
106
to
107
.B cons
108
causes the characters to be printed on the console screen.
109
.PP
110
The
111
.B osversion
112
file contains a textual representation of the operating system's version and parameters.
113
At the moment, it contains one field: the 9P protocol version, currently
114
.BR 2000 .
115
.PP
116
The
117
.B config
118
file contains a copy of the kernel configuration file used to build the kernel.
119
.PP
120
The
121
.B kmesg
122
file holds the last 16 kilobytes of output written to the console
123
by the kernel's print statements or by processes writing to
124
.BR /dev/cons .
125
It is useful for retrieving boot messages once the boot
126
process is over.
127
.PP
128
The
129
.B kprint
130
file may be read to receive a copy of the data written
131
to the console by the kernel's print statements or by processes
132
writing to
133
.BR /dev/cons .
134
Only data written after the file is opened is available.
135
If the machine's console is a serial line, the data is sent both to the
136
console and to
137
.BR kprint ;
138
if its console is a graphics screen, the data is sent either to the
139
display or to
140
.BR kprint ,
141
but not both.
142
(It is advisable not to open
143
.B kprint
144
on terminals until you have started
145
.IR rio (1).)
146
.PP
147
The
148
.B null
149
file throws away anything written to it
150
and always returns zero when read.
151
.PP
152
The
153
.B zero
154
file is a read-only file that produces an infinite stream of zero-valued bytes when read.
155
.PP
156
The
157
.B drivers
158
file contains, one per line, a listing of the drivers configured in the kernel, in the format
159
.IP
160
.EX
161
#c cons
162
.EE
163
.PP
164
The
165
.B hostdomain
166
file contains the name of the authentication domain that
167
this host belongs to; see
168
.IR authsrv (6).
169
Only the user named in
170
.B /dev/hostowner
171
may write this.
172
.PP
173
The
174
.B hostowner
175
file contains the name of the user that owns the console device files.
176
The hostowner also has group permissions for any local devices.
177
.PP
178
Reads from
179
.B random
180
return a stream of random numbers.  The numbers are
181
generated by a low priority kernel process that loops
182
incrementing a variable.  Each clock tick the variable
183
is sampled and, if it has changed sufficiently, the last
184
few bits are appended to a buffer.  This process is inefficient
185
at best producing at most a few hundred bits a second.
186
Therefore,
187
.B random
188
should be treated as a seed to
189
pseudo-random number generators which can produce a faster
190
rate stream.
191
.PP
192
Writing the string
193
.B reboot
194
to
195
.B reboot
196
causes the system to shutdown and, if
197
possible, restart.
198
Writing the string
199
.B reboot
200
.I kernelpath
201
loads the named kernel image and restarts,
202
preserving the kernel configuration in
203
.BR #ec ,
204
except that the
205
.B bootfile
206
variable is set to
207
.IR kernelpath .
208
Only the host
209
owner has the ability to open this file.
210
The named kernel may be a Plan 9 executable or
211
a 32-bit or 64-bit ELF executable.
212
On some architectures
213
(e.g.,
214
.BR mips ),
215
it may also be a Plan 9 boot image.
216
.PP
217
.B Bintime
218
is a binary interface that provides
219
the same information as
220
.B time
221
.RI ( q.v. ),
222
in binary form,
223
and also controls clock frequency and clock trim.
224
All integers read or written from
225
.B bintime
226
are in big endian order.
227
Unlike the other files, reads and writes do not affect
228
the offset.  Therefore, there is no need for a seek
229
back to zero between subsequent accesses.
230
A read of
231
.B bintime
232
returns 24 bytes, three 8 byte numbers, representing nanoseconds
233
since start of epoch, clock ticks, and clock frequency.
234
.PP
235
A write to
236
.B bintime
237
is a message with one of 3 formats:
238
.IP "\f5n\fP<8-byte \f2time\fP>" 1.2i
239
set the nanoseconds since epoch to the given
240
.IR time .
241
.IP "\f5d\fP<8-byte \f2delta\fP><4-byte \f2period\fP>" 1.2i
242
trim the nanoseconds since epoch by
243
.I delta
244
over the next
245
.I period
246
seconds.
247
.IP "\f5f\fP<8-byte \f2freq\fP>" 1.2i
248
Set the frequency for interpreting clock ticks to be
249
.I freq
250
ticks per second.
251
.SS "Statistics and Dynamic Status"
252
The rest of the files contain (mostly) read-only strings.
253
Each string has a fixed length: a
254
.IR read (2)
255
of more than that gives a result of that fixed length (the result does not
256
include a terminating zero byte);
257
a
258
.I read
259
of less than that length leaves the file offset so the
260
rest of the string (but no more) will be read the next time.
261
To reread the file without closing it,
262
.I seek
263
must be used to reset the offset.
264
When the file contains numeric data
265
each number is formatted in decimal.
266
If the binary number fits in 32 bits, it is formatted as an
267
11 digit decimal number with
268
leading blanks and one trailing blank; totaling 12 bytes.
269
Otherwise, it
270
is formatted as 21 digit decimal numbers with leading blanks and one
271
trailing blank; totaling 22 bytes.
272
.PP
273
The
274
.B cputime
275
file holds six 32-bit numbers, containing the time in milliseconds
276
that the current process has spent in user mode, system calls,
277
real elapsed time, and then the time spent, by exited children and their descendants,
278
in user mode, system calls, and real elapsed time.
279
.PP
280
The
281
.B time
282
file holds one 32-bit number representing the seconds since start of epoch
283
and three 64-bit numbers, representing nanoseconds since
284
start of epoch, clock ticks, and clock frequency.
285
.PP
286
A write of a decimal number to
287
.B time
288
will set the seconds since epoch.
289
.PP
290
The
291
.B sysname
292
file holds the textual name of the machine, e.g.
293
.BR kremvax ,
294
if known.
295
.PP
296
The
297
.B sysstat
298
file holds 10 numbers:
299
processor number, context switches, interrupts, system calls, page faults,
300
TLB faults, TLB purges, load average, idle time and time spent servicing interrupts.
301
The load average is in units of milli-CPUs and is decayed over time;
302
idle time and interrupt time are percentage units;
303
the others are total counts from boot time.
304
If the machine is a multiprocessor,
305
.B sysstat
306
holds one line per processor.
307
Writing anything to
308
.B sysstat
309
resets all of the counts on all processors.
310
.PP
311
The
312
.B swap
313
device holds a text block giving memory usage statistics:
314
.IP
315
.EX
316
\fIn\fP memory
317
\fIn\fP pagesize
318
\fIn\fP kernel
319
\fIn\fP/\fIm\fP user
320
\fIn\fP/\fIm\fP swap
321
\fIn\fP/\fIm\fP kernel malloc
322
\fIn\fP/\fIm\fP kernel draw
323
.EE
324
.PP
325
These are total memory (bytes), system page size (bytes),
326
kernel memory (pages), user memory (pages), swap space (pages),
327
kernel malloced data (bytes), and kernel graphics data (bytes).
328
The expression
329
.IR n / m
330
indicates
331
.I n
332
used out of
333
.I m
334
available.
335
These numbers are not blank padded.
336
.PP
337
To turn on swapping, write to
338
.B swap
339
the textual file descriptor number of a file or device on which to swap.
340
See
341
.IR swap (8).
342
.PP
343
The other files served by the
344
.I cons
345
device are all single numbers:
346
.TP 10
347
.B pgrpid
348
process group number
349
.TP
350
.B pid
351
process number
352
.TP
353
.B ppid
354
parent's process number
355
.SH SEE ALSO
356
.IR draw (3),
357
.IR keyboard (6),
358
.IR authsrv (6),
359
.IR utf (6),
360
.IR swap (8)
361
.SH SOURCE
362
.B /sys/src/9/port/devcons.c
363
.SH BUGS
364
For debugging, two control-T's followed by a letter
365
generate console output and manage debugging:
366
.L ^T^Td
367
toggles whether the console debugger will be run if the system fails.
368
.L ^T^TD
369
starts the console debugger immediately.
370
.L ^T^Tk
371
kills the largest process; use with care.
372
.L ^T^Tp
373
prints data about processes.
374
.L ^T^Tq
375
prints the run queue for processor 0.
376
.L ^T^Ts
377
prints the kernel stack.
378
.L ^T^Tx
379
prints data about kernel memory allocation.
380
.PP
381
The system can be rebooted by typing
382
.LR ^T^Tr .