All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Dr. Werner Fink" <werner@suse.de>
To: Alan Cox <alan@lxorguk.ukuu.org.uk>
Cc: Greg KH <greg@kroah.com>,
	Lennart Poettering <mzxreary@0pointer.de>,
	Kay Sievers <kay.sievers@vrfy.org>,
	Valdis.Kletnieks@vt.edu,
	linux-kernel <linux-kernel@vger.kernel.org>,
	Randy Dunlap <rdunlap@xenotime.net>, Jiri Slaby <jslaby@suse.cz>
Subject: Re: tty: add 'active' sysfs attribute to tty0 and console device
Date: Thu, 18 Nov 2010 13:12:56 +0100	[thread overview]
Message-ID: <20101118121256.GA19884@boole.suse.de> (raw)
In-Reply-To: <20101118112335.434de53a@lxorguk.ukuu.org.uk>

On Thu, Nov 18, 2010 at 11:23:35AM +0000, Alan Cox wrote:
> > is the most pressing case e.g. on s390 or zSeries) and this without
> > forcing (and maybe stealing) the controlling tty on the system console
> > to be able to detect the primary tty/console.
> 
> What do you mean by console in this context
> 
> The console in printk context and the "console" in "active vt window" are
> unrelated concepts with the same name, so its a bit confusing to follow
> here. 

Example: running a boot script on /dev/console and after fsck
sulogin has to called to be able to asked the system admin.
Now the question is which console device the system admin is
waiting in front of (before /dev/ttyS0 or /dev/tty3270 or whatever).

> > facilities (having device, read, write, and unblank) are also shown
> > in the new file /sys/class/tty/console/active ... but maybe Randy
> > could says a few words for what this is usable.
> 
> The system console does not even need to be a tty device, and on many
> embedded devices is not (it may for example by a RAM buffer not wiped
> over reboots or it may be jtag or MIPI trace ports.
> 
> "tty0" is *currently* a shorthand for "the VT the keyboard/display are
> showing". That's a shorthand that in itself will make no sense in future.

I'm aware of.  For using tty devices of the system console it requires
to have e.g. with my patch:

  bash> cat /proc/tty/consoles 
  tty0                 -WU (ECp)       4:7

the `W' flag for write and the major:minor pair, beside this the `U'
flag indicates the tty can do an unblank operation, the `-' shows that
there is no read operation (never seen such a console tty).  On an other
system here I see:

  bash> cat /proc/tty/consoles
  ttyS0                -W- (ECp)       4:64
  tty0                 -WU (Ep)        4:1

which I'm using in user space with

    dev_t dev = 0;
    FILE * fc;

    if ((fc = fopen("/proc/tty/consoles", "r"))) {
        char fbuf[16];
        int maj, min;
        while ((fscanf(fc, "%*s %*s (%[^)]) %d:%d", &fbuf[0], &maj, &min) == 3)) {
            if (!strchr(fbuf, 'E'))
                continue;
            if (strchr(fbuf, 'C')) {
                dev = makedev(maj, min);
                break;
            }
        }
        fclose(fc);
    }

to detect the primary console device here.


       Werner

-- 
  "Having a smoking section in a restaurant is like having
          a peeing section in a swimming pool." -- Edward Burr

  reply	other threads:[~2010-11-18 12:13 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-16 15:46 tty: add 'active' sysfs attribute to tty0 and console device Kay Sievers
2010-11-16 15:57 ` Alan Cox
2010-11-16 16:13   ` Kay Sievers
2010-11-16 17:14     ` Alan Cox
2010-11-16 18:51       ` Kay Sievers
2010-11-16 19:55         ` Alan Cox
2010-11-16 20:15           ` Kay Sievers
2010-11-16 20:49             ` Alan Cox
2010-11-16 21:29               ` Kay Sievers
2010-11-16 21:42               ` Lennart Poettering
2010-11-16 22:51                 ` Alan Cox
2010-11-16 22:58                   ` Lennart Poettering
2010-11-16 23:04                     ` Alan Cox
2010-11-16 23:18                       ` Lennart Poettering
2010-11-16 23:49                         ` Etched Pixels
2010-11-16 21:36           ` Lennart Poettering
2010-11-16 22:56             ` Alan Cox
2010-11-16 23:10               ` Lennart Poettering
2010-11-16 23:45                 ` Alan Cox
2010-11-17 16:31                 ` John Stoffel
2010-11-17 22:01                 ` Valdis.Kletnieks
2010-11-17 23:40                   ` Kay Sievers
2010-11-17 23:56                     ` Alan Cox
2010-11-18  1:27                       ` Greg KH
2010-11-18  1:48                         ` Lennart Poettering
2010-11-18  1:53                           ` Greg KH
2010-11-18  2:29                             ` Lennart Poettering
2010-11-18 11:00                             ` Dr. Werner Fink
2010-11-18 11:23                               ` Alan Cox
2010-11-18 12:12                                 ` Dr. Werner Fink [this message]
2010-11-18 12:58                                   ` Alan Cox
2010-11-18 13:14                                     ` Dr. Werner Fink
2010-11-18 14:41                                       ` Alan Cox
2010-11-19 13:21                                         ` Dr. Werner Fink
2010-11-19 15:47                                           ` Alan Cox
2010-11-19 17:07                                             ` Dr. Werner Fink
2010-11-19 18:02                                             ` Greg KH
2010-11-19 18:41                                               ` Dr. Werner Fink
2010-11-20 12:40                                                 ` Alan Cox
2010-12-01 11:15                                                   ` Dr. Werner Fink
2010-11-18 12:04                               ` Kay Sievers
2010-11-18 10:15                         ` Alan Cox
2010-11-18 11:55                           ` Kay Sievers
2010-11-18 13:01                             ` Alan Cox
     [not found] <20101201112004.12d78cd7@lxorguk.ukuu.org.uk>
2010-12-01 12:32 ` Dr. Werner Fink
     [not found]   ` <tiocgdev1@mdm.bga.com>
2010-12-03 11:48     ` Dr. Werner Fink

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20101118121256.GA19884@boole.suse.de \
    --to=werner@suse.de \
    --cc=Valdis.Kletnieks@vt.edu \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=greg@kroah.com \
    --cc=jslaby@suse.cz \
    --cc=kay.sievers@vrfy.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mzxreary@0pointer.de \
    --cc=rdunlap@xenotime.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.