aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/tty/vt/vt.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/tty/vt/vt.c')
-rw-r--r--drivers/tty/vt/vt.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c
index a8ec48ed14d..76407eca9ab 100644
--- a/drivers/tty/vt/vt.c
+++ b/drivers/tty/vt/vt.c
@@ -236,6 +236,14 @@ enum {
236}; 236};
237 237
238/* 238/*
239 * /sys/class/tty/tty0/
240 *
241 * the attribute 'active' contains the name of the current vc
242 * console and it supports poll() to detect vc switches
243 */
244static struct device *tty0dev;
245
246/*
239 * Notifier list for console events. 247 * Notifier list for console events.
240 */ 248 */
241static ATOMIC_NOTIFIER_HEAD(vt_notifier_list); 249static ATOMIC_NOTIFIER_HEAD(vt_notifier_list);
@@ -688,6 +696,8 @@ void redraw_screen(struct vc_data *vc, int is_switch)
688 save_screen(old_vc); 696 save_screen(old_vc);
689 set_origin(old_vc); 697 set_origin(old_vc);
690 } 698 }
699 if (tty0dev)
700 sysfs_notify(&tty0dev->kobj, NULL, "active");
691 } else { 701 } else {
692 hide_cursor(vc); 702 hide_cursor(vc);
693 redraw = 1; 703 redraw = 1;
@@ -2967,13 +2977,24 @@ static const struct tty_operations con_ops = {
2967 2977
2968static struct cdev vc0_cdev; 2978static struct cdev vc0_cdev;
2969 2979
2980static ssize_t show_tty_active(struct device *dev,
2981 struct device_attribute *attr, char *buf)
2982{
2983 return sprintf(buf, "tty%d\n", fg_console + 1);
2984}
2985static DEVICE_ATTR(active, S_IRUGO, show_tty_active, NULL);
2986
2970int __init vty_init(const struct file_operations *console_fops) 2987int __init vty_init(const struct file_operations *console_fops)
2971{ 2988{
2972 cdev_init(&vc0_cdev, console_fops); 2989 cdev_init(&vc0_cdev, console_fops);
2973 if (cdev_add(&vc0_cdev, MKDEV(TTY_MAJOR, 0), 1) || 2990 if (cdev_add(&vc0_cdev, MKDEV(TTY_MAJOR, 0), 1) ||
2974 register_chrdev_region(MKDEV(TTY_MAJOR, 0), 1, "/dev/vc/0") < 0) 2991 register_chrdev_region(MKDEV(TTY_MAJOR, 0), 1, "/dev/vc/0") < 0)
2975 panic("Couldn't register /dev/tty0 driver\n"); 2992 panic("Couldn't register /dev/tty0 driver\n");
2976 device_create(tty_class, NULL, MKDEV(TTY_MAJOR, 0), NULL, "tty0"); 2993 tty0dev = device_create(tty_class, NULL, MKDEV(TTY_MAJOR, 0), NULL, "tty0");
2994 if (IS_ERR(tty0dev))
2995 tty0dev = NULL;
2996 else
2997 device_create_file(tty0dev, &dev_attr_active);
2977 2998
2978 vcs_init(); 2999 vcs_init();
2979 3000