tty: Set correct tty name in 'active' sysfs attribute
PATCH v2 1/1 tty: Set correct tty name in 'active' sysfs attribute
The 'active' sysfs attribute should refer to the currently active tty devices the console is running on, not the currently active console.
The console structure doesn't refer to any device in sysfs, only the tty the console is running on has.
So we need to print out the tty names in 'active', not the console names.
--- drivers/tty/tty_io.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-)
drivers/tty/tty_io.c +17 -6
@@ -1271,12 +1271,13 @@ static void pty_line_name(struct tty_driver *driver, int index, char *p)* * Locking: None */ -static void tty_line_name (struct tty_driver *driver,int index,char *p) +static ssize_t tty_line_name (struct tty_driver *driver,int index,char *p) {if (driver->flags &TTY_DRIVER_UNNUMBERED_NODE ) -strcpy (p, driver->name); +return sprintf (p,"%s" , driver->name);else -sprintf (p,"%s%d" , driver->name, index + driver->name_base); +return sprintf (p,"%s%d" , driver->name, + index + driver->name_base); }/**
@@ -3545,9 +3546,19 @@ static ssize_t show_cons_active(struct device *dev,if (i >=ARRAY_SIZE (cs))break ; } -while (i--) - count +=sprintf (buf + count,"%s%d%c" , - cs[i]->name, cs[i]->index, i ?' ' :'\n' ); +while (i--) { +struct tty_driver *driver; +const char *name = cs[i]->name; +int index = cs[i]->index; + + driver = cs[i]->device (cs[i], &index); +if (driver) { + count +=tty_line_name (driver, index, buf + count); + count +=sprintf (buf + count,"%c" , i ?' ' :'\n' ); + }else + count +=sprintf (buf + count,"%s%d%c" , + name, index, i ?' ' :'\n' ); + }console_unlock ();return count;
Signature · 1 line
1.7.12.4
Greg Kroah-Hartman
maintainerQuoted 3 lines · Hannes Reinecke
The 'active' sysfs attribute should refer to the currently active tty devices the console is running on, not the currently active console.
That's not what Documentation/ABI/sysfs-tty says:
Shows the list of currently configured console devices, like 'tty1 ttyS0'. The last entry in the file is the active device connected to /dev/console. The file supports poll() to detect virtual console switches.
Quoted 2 lines
The console structure doesn't refer to any device in sysfs, only the tty the console is running on has.
That sentance doesn't make sense.
Quoted 2 lines
So we need to print out the tty names in 'active', not the console names.
But that doesn't match the documentation.
What exactly are you trying to "fix" here? What is the problem that the current file has that is broken? And as you are changing what this file means, what will break if the information in the file changes?
thanks,
greg k-h
Quoted 5 lines · Greg Kroah-Hartman
Quoted 3 lines · Hannes Reinecke
The 'active' sysfs attribute should refer to the currently active tty devices the console is running on, not the currently active console.
Quoted 8 lines
That's not what
Documentation/ABI/sysfs-ttysays:
Shows the list of currently configured console devices, like 'tty1 ttyS0'. The last entry in the file is the active device connected to/dev/console. The file supportspoll()to detect virtual console switches.
The problem is indeed with 'console devices'. There is no such thing; you only have tty devices where the console is running on.
Quoted 5 lines
Quoted 2 lines
The console structure doesn't refer to any device in sysfs, only the tty the console is running on has.
That sentance doesn't make sense.
Quoted 9 lines
Quoted 2 lines
So we need to print out the tty names in 'active', not the console names.
But that doesn't match the documentation.
What exactly are you trying to "fix" here? What is the problem that the current file has that is broken? And as you are changing what this file means, what will break if the information in the file changes?
systemd is using the 'active' sysfs attribute to figure out on which _tty_ device to start a getty on.
As soon as the console name and the tty name are different you have no means of figuring out which _device_ to open. AFAICS the console 'device' (ie the current entry in 'active') doesn't have _any_ equivalent in sysfs; it just so happens that for most console drivers the tty driver name is identical. But this is not a requirement, and fails for drivers which have a different device for the console and the tty.
EG on S/390 the 3270 tty has the devices
/dev/3270/tty1
but the console driver announces the name 'tty3270'. So as per current rules the 'active' attribute contains
tty32700
which correct as per documentation, but doesn't have _any_ equivalent in sysfs.
Martin has the grubby details here.
But of course, the documentation should be updated to match the new behavior.
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke zSeries & Storage [email protected] +49 911 74053 688 SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)
Greg Kroah-Hartman
maintainerQuoted 50 lines · Hannes Reinecke
Quoted 5 lines · Greg Kroah-Hartman
Quoted 3 lines · Hannes Reinecke
The 'active' sysfs attribute should refer to the currently active tty devices the console is running on, not the currently active console.
Quoted 8 lines
That's not what
Documentation/ABI/sysfs-ttysays:
Shows the list of currently configured console devices, like 'tty1 ttyS0'. The last entry in the file is the active device connected to/dev/console. The file supportspoll()to detect virtual console switches.The problem is indeed with 'console devices'. There is no such thing; you only have tty devices where the console is running on.
Quoted 5 lines
Quoted 2 lines
The console structure doesn't refer to any device in sysfs, only the tty the console is running on has.
That sentance doesn't make sense.
Quoted 9 lines
Quoted 2 lines
So we need to print out the tty names in 'active', not the console names.
But that doesn't match the documentation.
What exactly are you trying to "fix" here? What is the problem that the current file has that is broken? And as you are changing what this file means, what will break if the information in the file changes?
systemd is using the 'active' sysfs attribute to figure out on which _tty_ device to start a getty on.
As soon as the console name and the tty name are different you have no means of figuring out which _device_ to open. AFAICS the console 'device' (ie the current entry in 'active') doesn't have _any_ equivalent in sysfs; it just so happens that for most console drivers the tty driver name is identical. But this is not a requirement, and fails for drivers which have a different device for the console and the tty.EG on S/390 the 3270 tty has the devices
/dev/3270/tty1but the console driver announces the name 'tty3270'. So as per current rules the 'active' attribute contains
tty32700
Quoted 7 lines
which correct as per documentation, but doesn't have _any_ equivalent in sysfs.
Martin has the grubby details here.
But of course, the documentation should be updated to match the new behavior.
Ok, care to send an updated version, that fixes the Documentation as well? If Kay agrees that this is the correct solution, I'll be glad to take it.
thanks,
greg k-h
Quoted 54 lines · Greg Kroah-Hartman
Quoted 53 lines · Hannes Reinecke
Quoted 5 lines · Greg Kroah-Hartman
Quoted 3 lines · Hannes Reinecke
The 'active' sysfs attribute should refer to the currently active tty devices the console is running on, not the currently active console.
Quoted 8 lines
That's not what
Documentation/ABI/sysfs-ttysays:
Shows the list of currently configured console devices, like 'tty1 ttyS0'. The last entry in the file is the active device connected to/dev/console. The file supportspoll()to detect virtual console switches.The problem is indeed with 'console devices'. There is no such thing; you only have tty devices where the console is running on.
Quoted 5 lines
Quoted 2 lines
The console structure doesn't refer to any device in sysfs, only the tty the console is running on has.
That sentance doesn't make sense.
Quoted 9 lines
Quoted 2 lines
So we need to print out the tty names in 'active', not the console names.
But that doesn't match the documentation.
What exactly are you trying to "fix" here? What is the problem that the current file has that is broken? And as you are changing what this file means, what will break if the information in the file changes?
systemd is using the 'active' sysfs attribute to figure out on which _tty_ device to start a getty on.
As soon as the console name and the tty name are different you have no means of figuring out which _device_ to open. AFAICS the console 'device' (ie the current entry in 'active') doesn't have _any_ equivalent in sysfs; it just so happens that for most console drivers the tty driver name is identical. But this is not a requirement, and fails for drivers which have a different device for the console and the tty.EG on S/390 the 3270 tty has the devices
/dev/3270/tty1but the console driver announces the name 'tty3270'. So as per current rules the 'active' attribute contains
tty32700
which correct as per documentation, but doesn't have _any_ equivalent in sysfs.
Quoted 8 lines
Quoted 4 lines
Martin has the grubby details here.
But of course, the documentation should be updated to match the new behavior.
Ok, care to send an updated version, that fixes the Documentation as well? If Kay agrees that this is the correct solution, I'll be glad to take it.
Sounds good to me. The intention clearly was to point to the device in use, which we can find then.
I would not expect problems with this change. For common uses it is the same name already and nothing visibly should change, and for the ones where it isn't the same, I expect it is not too useful to find the driver name.
Thanks,
Kay
Quoted 2 lines
Sounds good to me. The intention clearly was to point to the device in use, which we can find then.
I would concur.
Quoted 4 lines
I would not expect problems with this change. For common uses it is the same name already and nothing visibly should change, and for the ones where it isn't the same, I expect it is not too useful to find the driver name.
Very few tools use it so if it doesn't break any distro init setups (upstart, sysvinit, oh and that other one....) it ought to be fine.
Alan