Re: [PATCH 28/49] tty: Add a new file /proc/tty/consoles

From: Dr. Werner Fink
Date: Wed Oct 27 2010 - 07:32:01 EST


On Wed, Oct 27, 2010 at 11:51:18AM +0200, Jiri Slaby wrote:
> On 10/27/2010 11:27 AM, Dr. Werner Fink wrote:
> > Such a list would be very helpful e.g. to extend sulogin
> > to be able to prompt for maintenance on all terminal lines
> > of the system console after e.g. failed fsck. Currently
> > only the preferred terminal line is prompted for maintenance.
>
> I think nobody objects to the /proc/tty/consoles. This is a good thing
> to have. The patch just needs to be fixed (and you already did and sent
> me in private).
>
> The objections are against the way how you find out the real tty behind
> /dev/console. The method to walk through fd, guessing private_data etc.
> is simply unacceptable.
>
> Actually couldn't you just use one of:
> 1) ttyprintk driver (well, this will insert mess into klog)
> 2) send the output to all enabled consoles in /proc/tty/consoles
> ?

Hmmm ... I've wonder about the comment on add_preferred_console()
of kernel/printk.c:

* add_preferred_console - add a device to the list of preferred consoles.
* @name: device name
* @idx: device index
* @options: options for this console
*
* The last preferred console added will be used for kernel messages
* and stdin/out/err for init. Normally this is used by console_setup
* above to handle user-supplied console arguments; however it can also
* be used by arch-specific code either to override the user or more
* commonly to provide a default console (ie from PROM variables) when
* the user has not supplied one.

that is that the first line always provides the preferred terminal
line. In other words the detection stuff is not required as long
as the statement in the comment for add_preferred_console() will
remain now and in future. Indeed register_console() reorders the
list of console drivers if the preferred terminal line will be
changed and this line is marked with the flag CON_CONSDEV.

Now as stdin/out/err for init resides on the preferred terminal
line this could be OK. If a program is runniung on /dev/console
then also its stdin is directed to the preferred console line.

Werner

--
System V style init programs - http://savannah.nongnu.org/projects/sysvinit/