[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: console on Niagara in 6.0.1



On Tue, Mar 22, 2011 at 02:58:05AM -0700, David Miller wrote:
> From: Jurij Smakov <jurij@wooyd.org>
> Date: Tue, 22 Mar 2011 09:34:32 +0000
> 
> > You may end up with console set to /dev/console if detection logic 
> > failed and a fall-through value has been used here:
> > 
> > http://git.debian.org/?p=d-i/rootskel.git;a=blob_plain;f=src/sbin/reopen-console-linux;hb=HEAD
> > 
> > Can you post dmesg output from this machine, booted via a serial 
> > console?
> 
> Device probing via dmesg parsing, wonderful... :-/ This really isn't
> going to ever work reliably.

Yeah, it's not great. In fact, I've found that it does not work on
my system either, no getty is put on the serial console. I'll 
investigate.
 
> So this code is going to see "ttyHV0" get enabled:
> 
> [    0.000000] console [tty0] enabled, bootconsole disabled
> [102839.004039] console [ttyHV0] enabled
> 
> But that doesn't tell you the serial device name under /dev
> 
> Not even close.
> 
> The device for console named ttyHV0 on this machine happens to be
> /dev/ttyS0, but it could have been /dev/ttyS1, or /dev/ttyS2, or
> similar depending upon the order in which the various serial drivers
> probed.
> 
> Console name to serial device name is not a 1 to 1 relationship.
> They can be, and are often, completely different.
> 
> The console name string is used for matching for kernel command
> line directives, but that's it.  You cannot use it to determine
> the /dev/* name for the underlying device.
> 
> As a result you now will have to add logic to this script so that it
> knows that this "ttyHV?" thing allocates from the "ttyS?" space, and
> then you will have to add code which figures out which index in the
> ttyS? space it got.
> 
> And there are a bunch of other serial device drivers which have the
> same issue.

I did not find a better way to find it for the squeeze kernel, but it 
appears that 2.6.38 supports a TIOCGDEV ioctl, which one can use on 
/dev/console to get the real device. With the following program

#include <stdio.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>

#define TIOCGDEV        _IOR('T',0x32, unsigned int)

main () {
        int fd = 0;
	unsigned int u, tty_major, tty_minor;
       
	fd = open("/dev/console", O_WRONLY, 0);
	if (fd  < 0) { 
                perror("open");
                return(1);
        }
        if (ioctl(fd, TIOCGDEV, &u) < 0) {
                perror("ioctl");
                return(2);
        }
	tty_major = (u >> 8) & 0xfff;
	tty_minor = (u & 0xff) | ((u >> 12) & 0xfff00);
        printf("%d:%d\n",tty_major, tty_minor);
}

I get:

jurij@debian:~$ uname -a
Linux debian 2.6.38-1-sparc64-smp #1 SMP Thu Mar 17 02:39:31 UTC 2011 sparc64 GNU/Linux
jurij@debian:~$ gcc console.c 
jurij@debian:~$ sudo ./a.out 
4:64
jurij@debian:~$ ls -al /dev/ttyS0
crw------- 1 root root 4, 64 Mar 22 22:43 /dev/ttyS0
jurij@debian:~$ 

If you could compile and run it on your machine, it would be very 
interesting to see whether you'll get /dev/ttyS0 or /dev/ttyHV0 (on my 
machine sunsab driver is used, and it's using 'ttyS' as prefix for 
both). At least, this potentially allows us to do a proper fix in the
next release.

Best regards,
-- 
Jurij Smakov                                           jurij@wooyd.org
Key: http://www.wooyd.org/pgpkey/                      KeyID: C99E03CC


Reply to: