From owner-freebsd-arch@FreeBSD.ORG Sat May 27 21:19:05 2006 Return-Path: X-Original-To: arch@freebsd.org Delivered-To: freebsd-arch@FreeBSD.ORG Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 4F84C16B4E2 for ; Sat, 27 May 2006 21:18:29 +0000 (UTC) (envelope-from phk@critter.freebsd.dk) Received: from pfepc.post.tele.dk (pfepc.post.tele.dk [195.41.46.237]) by mx1.FreeBSD.org (Postfix) with ESMTP id C626C43D4C for ; Sat, 27 May 2006 21:18:28 +0000 (GMT) (envelope-from phk@critter.freebsd.dk) Received: from critter.freebsd.dk (0x50a07cfc.naenxx7.adsl-dhcp.tele.dk [80.160.124.252]) by pfepc.post.tele.dk (Postfix) with ESMTP id 12FD38A0010 for ; Sat, 27 May 2006 23:18:26 +0200 (CEST) Received: from critter.freebsd.dk (localhost [127.0.0.1]) by critter.freebsd.dk (8.13.6/8.13.6) with ESMTP id k4RLIOlM016030 for ; Sat, 27 May 2006 23:18:25 +0200 (CEST) (envelope-from phk@critter.freebsd.dk) To: arch@freebsd.org From: Poul-Henning Kamp Date: Sat, 27 May 2006 23:18:24 +0200 Message-ID: <16029.1148764704@critter.freebsd.dk> Sender: phk@critter.freebsd.dk Cc: Subject: A sort of plan for consoles in FreeBSD X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 27 May 2006 21:19:13 -0000 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.