lkml.org 
[lkml]   [2010]   [Nov]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: tty: add 'active' sysfs attribute to tty0 and console device
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


\
 
 \ /
  Last update: 2010-11-18 13:15    [from the cache]
©2003-2011 Jasper Spaans