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