376 lines · 8.9 KB · Text
RawDownload
.TH CONS 3.SH NAMEcons \- console, clocks, process/process group ids, user, null, reboot, etc..SH SYNOPSIS.nf.B bind #c /dev .B /dev/bintime.B /dev/config.B /dev/cons.B /dev/consctl.B /dev/cputime.B /dev/drivers.B /dev/hostdomain.B /dev/hostowner.B /dev/kmesg.B /dev/kprint.B /dev/null.B /dev/osversion.B /dev/pgrpid.B /dev/pid.B /dev/ppid.B /dev/random.B /dev/reboot.B /dev/swap.B /dev/sysname.B /dev/sysstat.B /dev/time.B /dev/user.B /dev/zero.fi.SH DESCRIPTIONThe console device serves a one-level directorygiving access to the console andmiscellaneous information..PPReading the.B consfile returns characters typed on the keyboard.Normally, characters are buffered to enable erase and kill processing.A control-U,.LR ^U ,typed at the keyboard.I killsthe current input line (removes all charactersfrom the buffer of charactersnot yet read via.BR cons ),and a backspace.I erasesthe previous non-kill, non-erase character from the input buffer.Killing and erasing only delete characters back to, but not including,the last newline.Characters typed at the keyboard actually produce 16-bit runes (see.IR utf (6)),but the runes are translated into the variable-length.SM UTFencoding (see.IR utf (6))before putting them into the buffer.A.IR read (2)of length greater than zero causes the process to wait until anewline or a.L ^Dends the buffer, and then returns as much of the buffer as the argumentto.B readallows, but only up to one complete line.A terminating.L ^Dis not put into the buffer.If part of the line remains, the next.B readwill return bytes from that remainder and not part of any new linethat has been typed since..PPIfthe string.B rawonhas been written to the.B consctlfile and the file is still open,.B consis in.IR "raw mode" :characters are not echoed as they are typed,backspace,.L ^Uand.L ^Dare not treated specially,and characters are available to.I readas soon as they are typed.Ordinary mode is reentered when.B rawoffis written to.B consctlor this file is closed..PPA.I write(see.IR read (2))to.B conscauses the characters to be printed on the console screen..PPThe.B osversionfile contains a textual representation of the operating system's version and parameters.At the moment, it contains one field: the 9P protocol version, currently.BR 2000 ..PPThe.B configfile contains a copy of the kernel configuration file used to build the kernel..PPThe.B kmesgfile holds the last 16 kilobytes of output written to the consoleby the kernel's print statements or by processes writing to.BR /dev/cons .It is useful for retrieving boot messages once the bootprocess is over..PPThe.B kprintfile may be read to receive a copy of the data writtento the console by the kernel's print statements or by processeswriting to.BR /dev/cons .Only data written after the file is opened is available.If the machine's console is a serial line, the data is sent both to theconsole and to.BR kprint ;if its console is a graphics screen, the data is sent either to thedisplay or to.BR kprint ,but not both.(It is advisable not to open.B kprinton terminals until you have started.IR rio (1).).PPThe.B nullfile throws away anything written to itand always returns zero when read..PPThe.B zerofile is a read-only file that produces an infinite stream of zero-valued bytes when read..PPThe.B driversfile contains, one per line, a listing of the drivers configured in the kernel, in the format.IP.EX#c cons.EE.PPThe.B hostdomainfile contains the name of the authentication domain thatthis host belongs to; see.IR authsrv (6).Only the user named in.B /dev/hostownermay write this..PPThe.B hostownerfile contains the name of the user that owns the console device files.The hostowner also has group permissions for any local devices..PPReads from.B randomreturn a stream of random numbers.  The numbers aregenerated by a low priority kernel process that loopsincrementing a variable.  Each clock tick the variableis sampled and, if it has changed sufficiently, the lastfew bits are appended to a buffer.  This process is inefficientat best producing at most a few hundred bits a second.Therefore,.B randomshould be treated as a seed topseudo-random number generators which can produce a fasterrate stream..PPWriting the string.B rebootto.B rebootcauses the system to shutdown and, ifpossible, restart.Writing the string.B reboot.I kernelpathloads the named kernel image and restarts,preserving the kernel configuration in.BR #ec ,except that the.B bootfilevariable is set to.IR kernelpath .Only the hostowner has the ability to open this file..PP.B Bintimeis a binary interface that providesthe same information as.B time.RI ( q.v. ),in binary form,and also controls clock frequency and clock trim.All integers read or written from.B bintimeare in big endian order.Unlike the other files, reads and writes do not affectthe offset.  Therefore, there is no need for a seekback to zero between subsequent accesses.A read of.B bintimereturns 24 bytes, three 8 byte numbers, representing nanosecondssince start of epoch, clock ticks, and clock frequency..PPA write to.B bintimeis a message with one of 3 formats:.IP "\f5n\fP<8-byte \f2time\fP>" 1.2iset the nanoseconds since epoch to the given.IR time ..IP "\f5d\fP<8-byte \f2delta\fP><4-byte \f2period\fP>" 1.2itrim the nanoseconds since epoch by.I deltaover the next.I periodseconds..IP "\f5f\fP<8-byte \f2freq\fP>" 1.2iSet the frequency for interpreting clock ticks to be.I freqticks per second..PPThe rest of the files contain (mostly) read-only strings.Each string has a fixed length: a.IR read (2)of more than that gives a result of that fixed length (the result does notinclude a terminating zero byte);a.I readof less than that length leaves the file offset so therest of the string (but no more) will be read the next time.To reread the file without closing it,.I seekmust be used to reset the offset.When the file contains numeric dataeach number is formatted in decimal.If the binary number fits in 32 bits, it is formatted as an11 digit decimal number withleading blanks and one trailing blank; totaling 12 bytes.Otherwise, itis formatted as 21 digit decimal numbers with leading blanks and onetrailing blank; totaling 22 bytes..PPThe.B cputimefile holds six 32-bit numbers, containing the time in millisecondsthat the current process has spent in user mode, system calls,real elapsed time, and then the time spent, by exited children and their descendants,in user mode, system calls, and real elapsed time..PPThe.B timefile holds one 32-bit number representing the seconds since start of epochand three 64-bit numbers, representing nanoseconds sincestart of epoch, clock ticks, and clock frequency..PPA write of a decimal number to.B timewill set the seconds since epoch..PPThe.B sysnamefile holds the textual name of the machine, e.g..BR kremvax ,if known..PPThe.B sysstatfile holds 10 numbers:processor number, context switches, interrupts, system calls, page faults,TLB faults, TLB purges, load average, idle time and time spent servicing interrupts.The load average is in units of milli-CPUs and is decayed over time;idle time and interrupt time are percentage units;the others are total counts from boot time.If the machine is a multiprocessor,.B sysstatholds one line per processor.Writing anything to.B sysstatresets all of the counts on all processors..PPThe.B swapdevice holds a text block giving memory usage statistics:.IP.EX\fIn\fP memory\fIn\fP pagesize\fIn\fP kernel\fIn\fP/\fIm\fP user\fIn\fP/\fIm\fP swap\fIn\fP/\fIm\fP kernel malloc\fIn\fP/\fIm\fP kernel draw.EE.PPThese are total memory (bytes), system page size (bytes),kernel memory (pages), user memory (pages), swap space (pages),kernel malloced data (bytes), and kernel graphics data (bytes).The expression.IR n / mindicates.I nused out of.I mavailable.These numbers are not blank padded..PPTo turn on swapping, write to.B swapthe textual file descriptor number of a file or device on which to swap.See.IR swap (8)..PPThe other files served by the.I consdevice are all single numbers:.TP 10.B pgrpidprocess group number.TP.B pidprocess number.TP.B ppidparent's process number.SH SEE ALSO.IR draw (3),.IR keyboard (6),.IR authsrv (6),.IR utf (6),.IR swap (8).SH SOURCE.B /sys/src/9/port/devcons.c.SH BUGSFor debugging, two control-T's followed by a lettergenerate console output and manage debugging:.L ^T^Tdtoggles whether the console debugger will be run if the system fails..L ^T^TDstarts the console debugger immediately..L ^T^Tkkills the largest process; use with care..L ^T^Tpprints data about processes..L ^T^Tqprints the run queue for processor 0..L ^T^Tsprints the kernel stack..L ^T^Txprints data about kernel memory allocation..PPThe system can be rebooted by typing.LR ^T^Tr .