add class/tty/console/real_dev symlink
PATCH 1/1 add class/tty/console/real_dev symlink
This patch adds a symlink from /sys/class/tty/console/real_dev to e.g. /sys/class/tty/ttyS0 . This is needed because there is no way for userspace to determine what device the kernel is using as its console, and in the case of an installer that is important information. Otherwise, the installer cannot know which serial port you're booting on, for example, and so wouldn't know where to display itself.
This "works for me". I'm not overly attached to the name of the symlink though. Comments?
Signature · 49 lines
Hollis Blanchard
IBM Linux Technology Center
===== drivers/char/tty_io.c 1.147 vs edited =====
--- 1.147/drivers/char/tty_io.c Sat Oct 2 17:45:19 2004
+++ edited/drivers/char/tty_io.c Wed Oct 6 17:08:27 2004
@@ -110,6 +110,8 @@
#define TTY_PARANOIA_CHECK 1
#define CHECK_TTY_COUNT 1
+static struct class_device *console_dev;
+
struct termios tty_std_termios = { /* for the benefit of tty drivers */
.c_iflag = ICRNL | IXON,
.c_oflag = OPOST | ONLCR,
@@ -2640,6 +2642,9 @@
{
char name[64];
dev_t dev = MKDEV(driver->major, driver->minor_start) + index;
+ struct class_device *tty_dev;
+ struct tty_driver *console_driver;
+ int console_index;
if (index >= driver->num) {
printk(KERN_ERR "Attempt to register invalid tty line number "
@@ -2654,7 +2659,12 @@
pty_line_name(driver, index, name);
else
tty_line_name(driver, index, name);
- class_simple_device_add(tty_class, dev, device, name);
+ tty_dev = class_simple_device_add(tty_class, dev, device, name);
+
+ console_driver = console_device(&console_index);
+ if ((console_driver == driver) && (console_index == index)) {
+ sysfs_create_link(&console_dev->kobj, &tty_dev->kobj, "real_dev");
+ }
}
/**
@@ -2921,7 +2931,8 @@
register_chrdev_region(MKDEV(TTYAUX_MAJOR, 1), 1, "/dev/console") < 0)
panic("Couldn't register /dev/console driver\n");
devfs_mk_cdev(MKDEV(TTYAUX_MAJOR, 1), S_IFCHR|S_IRUSR|S_IWUSR, "console");
- class_simple_device_add(tty_class, MKDEV(TTYAUX_MAJOR, 1), NULL, "console");
+ console_dev = class_simple_device_add(tty_class, MKDEV(TTYAUX_MAJOR, 1),
+ NULL, "console");
#ifdef CONFIG_UNIX98_PTYS
cdev_init(&ptmx_cdev, &ptmx_fops);Quoted 6 lines · Hollis Blanchard
This patch adds a symlink from
/sys/class/tty/console/real_devto e.g./sys/class/tty/ttyS0. This is needed because there is no way for userspace to determine what device the kernel is using as its console, and in the case of an installer that is important information. Otherwise, the installer cannot know which serial port you're booting on, for example, and so wouldn't know where to display itself.
The installer can just open /dev/console?
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds