Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 27 May 2006 23:18:24 +0200
From:      Poul-Henning Kamp <phk@phk.freebsd.dk>
To:        arch@freebsd.org
Subject:   A sort of plan for consoles in FreeBSD
Message-ID:  <16029.1148764704@critter.freebsd.dk>

next in thread | raw e-mail | index | archive | help

We have four concepts of "console" in FreeBSD:

1. Whatever boot0/boot1/boot2/loader uses
    Accessed from/via native boot/firmware environment

2. The boot/DDB/printf(9)/panic(9) console ("The low-level console").
    Polled operation since interrupts may not be working.

3. The tty which /sbin/init uses for single-user and /etc/rc
    Can be any tty, but convention has been "/dev/console"

4. The /dev/console device in multi-user mode.
    Emergency output device for critical messages.

Most often they will all four end up referring to the same piece
of hardware (a good thing), but do not let this confuse you into
beliving they are one and the same thing.

The problem I'm trying to solve involves #4, the /dev/console device
which currently has a rather nasty way of forcing the underlying
console device driver open.

Seen in the light of history, spitting messages out on /dev/console
was the right thing to do back in the 1980ies, but the operators,
(or tape-monkeys as we were called back then), and their DecWriter
terminals hooked up to the VAX780 computers exist only in museums
these days, and they didn't run FreeBSD7 anyway.

Today we expect all relevant logging to happen to logfiles, either
directly (like for instance apache provides for) or via syslogd(8),
which adds the ability to send the logs to a remote machine in
real-time.

Spitting things out on /dev/console today will more likely than
not, print stuff on a syscons or serial port which nobody looks at.
For that reason, we added a hack to the kernel to make all stuff
that went to /dev/console be sent to syslogd(8).

I would like to redefine the semantics of "/dev/console" as follows:

	if any console-consumers like xconsole(8) are active
		send output to all console-consumers.
	else if a controlling terminal is available
		send output to controlling terminal (that is /dev/tty)
	else
		send output to syslogd, as if generated by printf(9).
		(but do not actually output to low-level console)

If xconsole(8) or similar programs are run, or if syslogd(8) is
told to record all console output, they will get what they expect.
Alternatively, we try to send the message to the relevant user and
if that fails (for daemons) we log it in syslog.

This also involves number #3 from the list because today /sbin/init
opens /dev/console for single user mode and /etc/rc.  But /sbin/init
can use any tty device so adding the necessary code to make the
low-level console communicate the relevant tty name to /sbin/init,
possibly making it overridable from the loader with a hint, will
take care of that.

Comments, ideas, suggestions etc welcome

Poul-Henning
-- 
Poul-Henning Kamp       | UNIX since Zilog Zeus 3.20
phk@FreeBSD.ORG         | TCP/IP since RFC 956
FreeBSD committer       | BSD since 4.3-tahoe
Never attribute to malice what can adequately be explained by incompetence.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?16029.1148764704>