]> git.lizzy.rs Git - plan9front.git/blob - sys/man/3/cons
authsrv(6): fix arrows
[plan9front.git] / sys / man / 3 / cons
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/cputime
12 .B /dev/drivers
13 .B /dev/hostdomain
14 .B /dev/hostowner
15 .B /dev/kmesg
16 .B /dev/kprint
17 .B /dev/mordor
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 screen and
35 miscellaneous information.
36 .PP
37 A
38 .I write
39 (see
40 .IR read (2))
41 to
42 .B cons
43 causes the characters to be printed on the console screen. Console
44 input is handled by a different program (see
45 .IR kbdfs (8)).
46 .PP
47 The
48 .B osversion
49 file contains a textual representation of the operating system's version and parameters.
50 At the moment, it contains one field: the 9P protocol version, currently
51 .BR 2000 .
52 .PP
53 The
54 .B config
55 file contains a copy of the kernel configuration file used to build the kernel.
56 .PP
57 The
58 .B kmesg
59 file holds the last 16 kilobytes of output written to the console
60 by the kernel's print statements or by processes writing to
61 .BR /dev/cons .
62 It is useful for retrieving boot messages once the boot
63 process is over.
64 .PP
65 The
66 .B kprint
67 file may be read to receive a copy of the data written
68 to the console by the kernel's print statements or by processes
69 writing to
70 .BR /dev/cons .
71 Only data written after the file is opened is available.
72 If the machine's console is a serial line, the data is sent both to the
73 console and to
74 .BR kprint ;
75 if its console is a graphics screen, the data is sent either to the
76 display or to
77 .BR kprint ,
78 but not both.
79 (It is advisable not to open
80 .B kprint
81 on terminals until you have started
82 .IR rio (1).)
83 .PP
84 The
85 .B null
86 file throws away anything written to it
87 and always returns zero when read.
88 .PP
89 The
90 .B zero
91 file is a read-only file that produces an infinite stream of zero-valued bytes when read.
92 .PP
93 The
94 .B drivers
95 file contains, one per line, a listing of the drivers configured in the kernel, in the format
96 .IP
97 .EX
98 #c cons
99 .EE
100 .PP
101 The
102 .B hostdomain
103 file contains the name of the authentication domain that
104 this host belongs to; see
105 .IR authsrv (6).
106 Only the user named in
107 .B /dev/hostowner
108 may write this.
109 .PP
110 The
111 .B hostowner
112 file contains the name of the user that owns the console device files.
113 The hostowner also has group permissions for any local devices.
114 .PP
115 Reads from
116 .B random
117 return a stream of random numbers.  The numbers are
118 generated by a low priority kernel process that loops
119 incrementing a variable.  Each clock tick the variable
120 is sampled and, if it has changed sufficiently, the last
121 few bits are appended to a buffer.  This process is inefficient
122 at best producing at most a few hundred bits a second.
123 Therefore,
124 .B random
125 should be treated as a seed to
126 pseudo-random number generators which can produce a faster
127 rate stream.
128 .PP
129 Writing the string
130 .B reboot
131 to
132 .B reboot
133 causes the system to shutdown and, if
134 possible, restart.
135 Writing the string
136 .B reboot
137 .I kernelpath
138 loads the named kernel image and restarts,
139 preserving the kernel configuration in
140 .BR #ec ,
141 except that the
142 .B bootfile
143 variable is set to
144 .IR kernelpath .
145 Writing the string
146 .B rdb
147 activates the remote kernel debugger (see
148 .IR rdbfs (4)).
149 Only the host
150 owner has the ability to open this file.
151 .PP
152 .B Bintime
153 is a binary interface that provides
154 the same information as
155 .B time
156 .RI ( q.v. ),
157 in binary form,
158 and also controls clock frequency and clock trim.
159 All integers read or written from
160 .B bintime
161 are in big endian order.
162 Unlike the other files, reads and writes do not affect
163 the offset.  Therefore, there is no need for a seek
164 back to zero between subsequent accesses.
165 A read of
166 .B bintime
167 returns 24 bytes, three 8 byte numbers, representing nanoseconds
168 since start of epoch, clock ticks, and clock frequency.
169 .PP
170 A write to
171 .B bintime
172 is a message with one of 3 formats:
173 .IP "\f5n\fP<8-byte \f2time\fP>" 1.2i
174 set the nanoseconds since epoch to the given
175 .IR time .
176 .IP "\f5d\fP<8-byte \f2delta\fP><4-byte \f2period\fP>" 1.2i
177 trim the nanoseconds since epoch by
178 .I delta
179 over the next
180 .I period
181 seconds.
182 .IP "\f5f\fP<8-byte \f2freq\fP>" 1.2i
183 Set the frequency for interpreting clock ticks to be
184 .I freq
185 ticks per second.
186 .PP
187 The rest of the files contain (mostly) read-only strings.
188 Each string has a fixed length: a
189 .IR read (2)
190 of more than that gives a result of that fixed length (the result does not
191 include a terminating zero byte);
192 a
193 .I read
194 of less than that length leaves the file offset so the
195 rest of the string (but no more) will be read the next time.
196 To reread the file without closing it,
197 .I seek
198 must be used to reset the offset.
199 When the file contains numeric data
200 each number is formatted in decimal.
201 If the binary number fits in 32 bits, it is formatted as an
202 11 digit decimal number with
203 leading blanks and one trailing blank; totaling 12 bytes.
204 Otherwise, it
205 is formatted as 21 digit decimal numbers with leading blanks and one
206 trailing blank; totaling 22 bytes.
207 .PP
208 The
209 .B cputime
210 file holds six 32-bit numbers, containing the time in milliseconds
211 that the current process has spent in user mode, system calls,
212 real elapsed time, and then the time spent, by exited children and their descendants,
213 in user mode, system calls, and real elapsed time.
214 .PP
215 The
216 .B time
217 file holds one 32-bit number representing the seconds since start of epoch
218 and three 64-bit numbers, representing nanoseconds since
219 start of epoch, clock ticks, and clock frequency.
220 .PP
221 A write of a decimal number to
222 .B time
223 will set the seconds since epoch.
224 .PP
225 The
226 .B sysname
227 file holds the textual name of the machine, e.g.
228 .BR kremvax ,
229 if known.
230 .PP
231 The
232 .B sysstat
233 file holds 10 numbers:
234 processor number, context switches, interrupts, system calls, page faults,
235 TLB faults, TLB purges, load average, idle time and time spent servicing interrupts.
236 The load average is in units of milli-CPUs and is decayed over time;
237 idle time and interrupt time are percentage units;
238 the others are total counts from boot time.
239 If the machine is a multiprocessor,
240 .B sysstat
241 holds one line per processor.
242 Writing anything to
243 .B sysstat
244 resets all of the counts on all processors.
245 .PP
246 The
247 .B swap
248 device holds a text block giving memory usage statistics:
249 .IP
250 .EX
251 \fIn\fP memory
252 \fIn\fP pagesize
253 \fIn\fP kernel
254 \fIn\fP/\fIm\fP user
255 \fIn\fP/\fIm\fP swap
256 \fIa\fP/\fIn\fP/\fIm\fP kernel malloc
257 \fIa\fP/\fIn\fP/\fIm\fP kernel draw
258 .EE
259 .PP
260 These are total memory (bytes), system page size (bytes),
261 kernel memory (pages), user memory (pages), swap space (pages),
262 kernel malloced data (bytes), and kernel graphics data (bytes).
263 The expression
264 .IR n / m
265 indicates
266 .I n
267 used out of
268 .I m
269 available.
270 For kernel malloc and kernel draw,
271 .IR a
272 indicates the current allocation in bytes.
273 These numbers are not blank padded.
274 .PP
275 To turn on swapping, write to
276 .B swap
277 the textual file descriptor number of a file or device on which to swap.
278 See
279 .IR swap (8).
280 .PP
281 Reads and writes to
282 .IR mordor
283 will inevitably cause the front to fall off.
284 .PP
285 The other files served by the
286 .I cons
287 device are all single numbers:
288 .TP 10
289 .B pgrpid
290 process group number
291 .TP
292 .B pid
293 process number
294 .TP
295 .B ppid
296 parent's process number
297 .SH SEE ALSO
298 .IR draw (3),
299 .IR kbd (3),
300 .IR kbdfs (8),
301 .IR keyboard (6),
302 .IR authsrv (6),
303 .IR utf (6),
304 .IR swap (8)
305 .SH SOURCE
306 .B /sys/src/9/port/devcons.c