mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [patch] add class/tty/console/real_dev symlink
@ 2004-10-06 18:30 Hollis Blanchard
  2004-10-07 16:28 ` Geert Uytterhoeven
  0 siblings, 1 reply; 2+ messages in thread
From: Hollis Blanchard @ 2004-10-06 18:30 UTC (permalink / raw)
  To: linux-kernel; +Cc: greg, katzj

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?

-- 
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);

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2004-10-07 17:03 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-10-06 18:30 [patch] add class/tty/console/real_dev symlink Hollis Blanchard
2004-10-07 16:28 ` Geert Uytterhoeven

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®