| From | Sent On | Attachments |
|---|---|---|
| Kay Sievers | Nov 16, 2010 7:46 am | |
| Alan Cox | Nov 16, 2010 7:56 am | |
| Kay Sievers | Nov 16, 2010 8:12 am | |
| Alan Cox | Nov 16, 2010 9:14 am | |
| Kay Sievers | Nov 16, 2010 10:51 am | |
| Alan Cox | Nov 16, 2010 11:55 am | |
| Kay Sievers | Nov 16, 2010 12:15 pm | |
| Alan Cox | Nov 16, 2010 12:48 pm | |
| Kay Sievers | Nov 16, 2010 1:28 pm | |
| Lennart Poettering | Nov 16, 2010 1:35 pm | |
| Lennart Poettering | Nov 16, 2010 1:42 pm | |
| Alan Cox | Nov 16, 2010 2:51 pm | |
| Alan Cox | Nov 16, 2010 2:55 pm | |
| Lennart Poettering | Nov 16, 2010 2:58 pm | |
| Alan Cox | Nov 16, 2010 3:04 pm | |
| Lennart Poettering | Nov 16, 2010 3:10 pm | |
| Lennart Poettering | Nov 16, 2010 3:18 pm | |
| Alan Cox | Nov 16, 2010 3:45 pm | |
| Etched Pixels | Nov 16, 2010 3:49 pm | |
| John Stoffel | Nov 17, 2010 8:31 am | |
| Vald...@vt.edu | Nov 17, 2010 2:00 pm | |
| Kay Sievers | Nov 17, 2010 3:39 pm | |
| Alan Cox | Nov 17, 2010 3:56 pm | |
| Greg KH | Nov 17, 2010 5:27 pm | |
| Lennart Poettering | Nov 17, 2010 5:48 pm | |
| Greg KH | Nov 17, 2010 5:52 pm | |
| Lennart Poettering | Nov 17, 2010 6:28 pm | |
| Alan Cox | Nov 18, 2010 2:14 am | |
| Dr. Werner Fink | Nov 18, 2010 2:59 am | |
| Alan Cox | Nov 18, 2010 3:23 am | |
| Kay Sievers | Nov 18, 2010 3:54 am | |
| Kay Sievers | Nov 18, 2010 4:03 am | |
| Dr. Werner Fink | Nov 18, 2010 4:12 am | |
| Alan Cox | Nov 18, 2010 4:57 am | |
| Alan Cox | Nov 18, 2010 5:00 am | |
| Dr. Werner Fink | Nov 18, 2010 5:13 am | |
| Alan Cox | Nov 18, 2010 6:41 am | |
| Dr. Werner Fink | Nov 19, 2010 5:21 am | |
| Alan Cox | Nov 19, 2010 7:46 am | |
| Dr. Werner Fink | Nov 19, 2010 9:06 am | .tiocgdev |
| Greg KH | Nov 19, 2010 10:02 am | |
| Dr. Werner Fink | Nov 19, 2010 10:41 am | |
| Alan Cox | Nov 20, 2010 4:39 am | |
| Dr. Werner Fink | Dec 1, 2010 3:15 am | |
| Dr. Werner Fink | Dec 1, 2010 4:31 am | .tiocgdev |
| Dr. Werner Fink | Dec 3, 2010 3:47 am | .Other |
| Subject: | Re: tty: add 'active' sysfs attribute to tty0 and console device | |
|---|---|---|
| From: | Alan Cox (al...@lxorguk.ukuu.org.uk) | |
| Date: | Nov 16, 2010 7:56:54 am | |
| List: | org.kernel.vger.linux-kernel | |
On Tue, 16 Nov 2010 16:46:40 +0100 Kay Sievers <kay....@vrfy.org> wrote:
commit be0d5f02c9194fe41c1aad11d7282db117bda938 Author: Kay Sievers <kay....@vrfy.org> Date: Tue Nov 9 18:53:59 2010 +0100
tty: add 'active' sysfs attribute to tty0 and console device
This is all somewhat weird.
Userspace can query the actual virtual console, and the configured console devices behind /dev/tt0 and /dev/console.
All the other vt interface code is in the vt driver, the ioctls for it are in the vt driver and a query about what is the active vt only has meaning within that context as you need to post a waitevent first to track changes during the query. So if you need a VT_GETACTIVE interface put it in the tty ioctls where it can be properly locked and used.
+What: /sys/class/tty/tty0/active +Date: Nov 2010 +Contact: Kay Sievers <kay....@vrfy.org> +Description: + Shows the currently active virtual console + device, like 'tty1'. + The file supports poll() to detect virtual + console switches.
NAK this, its a nonsense interface
Seriously what use is an interface that tells you "what the console might have been", this is why we have a proper event tracking interface instead.
+static ssize_t show_cons_active(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct console *cs[16]; + int i = 0; + struct console *c; + ssize_t count = 0; + + acquire_console_sem(); + for (c = console_drivers; c; c = c->next) { + if (!c->device) + continue; + if (!c->write) + continue; + if ((c->flags & CON_ENABLED) == 0) + continue; + cs[i++] = c; + if (i >= ARRAY_SIZE(cs)) + break; + } + while (i--) + count += sprintf(buf + count, "%s%d%c", + cs[i]->name, cs[i]->index, i ? ' ':'\n'); + release_console_sem(); + + return count; +} +static DEVICE_ATTR(active, S_IRUGO, show_cons_active, NULL);
This makes more sense.
- device_create(tty_class, NULL, MKDEV(TTYAUX_MAJOR, 0), NULL, - "tty"); + device_create(tty_class, NULL, MKDEV(TTYAUX_MAJOR, 0), NULL, "tty");
Please keep unneccessary reformatting patches out of code changes, submit them separately.
static ATOMIC_NOTIFIER_HEAD(vt_notifier_list); @@ -688,6 +696,8 @@ void redraw_screen(struct vc_data *vc, int is_switch) save_screen(old_vc); set_origin(old_vc); } + if (tty0dev) + sysfs_notify(&tty0dev->kobj, NULL, "active");
What is the locking on tty0dev at this point ? Wrong place anyway - we have vt change notifiers that do this properly and can track other changes like console sizes, add and remove. See the VT_WAITACTIVE stuff etc.
+static ssize_t show_tty_active(struct device *dev, + struct device_attribute *attr, char *buf) +{ + return sprintf(buf, "tty%d\n", fg_console + 1); +} +static DEVICE_ATTR(active, S_IRUGO, show_tty_active, NULL);
How do you ensure fg_console returned to user space is right when the console can change during and after the call ?
-- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majo...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/






.tiocgdev