* [PATCH 2/5] VT binding: Add sysfs support
@ 2006-06-09 8:39 Antonino A. Daplas
2006-06-09 22:08 ` Greg KH
0 siblings, 1 reply; 5+ messages in thread
From: Antonino A. Daplas @ 2006-06-09 8:39 UTC (permalink / raw)
To: Andrew Morton
Cc: Greg KH, Linux Fbdev development list, Linux Kernel Development
Add sysfs attributes for binding and unbinding VT console drivers. The
attributes are located in /sys/class/tty/console and are namely:
A. backend - list registered drivers in the following format:
"I C: Description"
Where: I = ID number of the driver
C = status of the driver which can be:
S = system driver
B = bound modular driver
U = unbound modular driver
Description - text description of the driver
B. bind - binds a driver to the console layer
echo <ID> > /sys/class/tty/console/bind
C. unbind - unbinds a driver from the console layer
echo <ID> > /sys/class/tty/console/unbind
The tty layer does nothing to these attributes except create them and punt all
requests to the VT layer.
Signed-off-by: Antonino Daplas <pol.net>
---
drivers/char/tty_io.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++++-
include/linux/tty.h | 19 ++++++++++++++++++
2 files changed, 71 insertions(+), 1 deletions(-)
diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c
index a5730a6..e23d360 100644
--- a/drivers/char/tty_io.c
+++ b/drivers/char/tty_io.c
@@ -3231,6 +3231,47 @@ #ifdef CONFIG_VT
static struct cdev vc0_cdev;
#endif
+static ssize_t store_bind(struct class_device *class_device,
+ const char *buf, size_t count)
+{
+ int index = simple_strtoul(buf, NULL, 0);
+
+ vt_bind(index);
+ return count;
+}
+
+static ssize_t store_unbind(struct class_device *class_device,
+ const char *buf, size_t count)
+{
+ int index = simple_strtoul(buf, NULL, 0);
+
+ vt_unbind(index);
+ return count;
+}
+
+static ssize_t show_con_drivers(struct class_device *class_device, char *buf)
+{
+ return vt_show_drivers(buf);
+}
+
+static struct class_device_attribute class_device_attrs[] = {
+ __ATTR(bind, S_IWUSR, NULL, store_bind),
+ __ATTR(unbind, S_IWUSR, NULL, store_unbind),
+ __ATTR(backend, S_IRUGO, show_con_drivers, NULL),
+};
+
+static struct class_device *console_class_device;
+
+static int console_init_class_device(void)
+{
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE(class_device_attrs); i++)
+ class_device_create_file(console_class_device,
+ &class_device_attrs[i]);
+ return 0;
+}
+
/*
* Ok, now we can initialize the rest of the tty devices and can count
* on memory allocations, interrupts etc..
@@ -3249,7 +3290,17 @@ static int __init tty_init(void)
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_device_create(tty_class, NULL, MKDEV(TTYAUX_MAJOR, 1), NULL, "console");
+ console_class_device = class_device_create(tty_class, NULL,
+ MKDEV(TTYAUX_MAJOR, 1),
+ NULL, "console");
+ if (IS_ERR(console_class_device)) {
+ printk(KERN_WARNING "Unable to create class device "
+ "for console; errno = %ldn",
+ PTR_ERR(console_class_device));
+ console_class_device = NULL;
+ } else
+ console_init_class_device();
+
#ifdef CONFIG_UNIX98_PTYS
cdev_init(&ptmx_cdev, &ptmx_fops);
diff --git a/include/linux/tty.h b/include/linux/tty.h
index cb35ca5..3edaa5d 100644
--- a/include/linux/tty.h
+++ b/include/linux/tty.h
@@ -347,6 +347,25 @@ extern void console_print(const char *);
extern int vt_ioctl(struct tty_struct *tty, struct file * file,
unsigned int cmd, unsigned long arg);
+#ifdef CONFIG_VT
+extern int vt_bind(int index);
+extern int vt_unbind(int index);
+extern int vt_show_drivers(char *buf);
+#else
+static inline int vt_bind(int index)
+{
+ return 0;
+}
+static inline int vt_unbind(int index)
+{
+ return 0;
+}
+static inline int vt_show_drivers(char *buf)
+{
+ return 0;
+}
+#endif
+
static inline dev_t tty_devnum(struct tty_struct *tty)
{
return MKDEV(tty->driver->major, tty->driver->minor_start) + tty->index;
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 2/5] VT binding: Add sysfs support
2006-06-09 8:39 [PATCH 2/5] VT binding: Add sysfs support Antonino A. Daplas
@ 2006-06-09 22:08 ` Greg KH
2006-06-10 0:38 ` Antonino A. Daplas
0 siblings, 1 reply; 5+ messages in thread
From: Greg KH @ 2006-06-09 22:08 UTC (permalink / raw)
To: Antonino A. Daplas
Cc: Andrew Morton, Linux Fbdev development list,
Linux Kernel Development
On Fri, Jun 09, 2006 at 04:39:51PM +0800, Antonino A. Daplas wrote:
> Add sysfs attributes for binding and unbinding VT console drivers. The
> attributes are located in /sys/class/tty/console and are namely:
>
> A. backend - list registered drivers in the following format:
>
> "I C: Description"
No, this violates the "one value per file" issue with sysfs. How do you
know you will not overflow the buffer passed to you?
>
> Where: I = ID number of the driver
> C = status of the driver which can be:
>
> S = system driver
> B = bound modular driver
> U = unbound modular driver
>
> Description - text description of the driver
>
> B. bind - binds a driver to the console layer
>
> echo <ID> > /sys/class/tty/console/bind
>
> C. unbind - unbinds a driver from the console layer
>
> echo <ID> > /sys/class/tty/console/unbind
>
> The tty layer does nothing to these attributes except create them and punt all
> requests to the VT layer.
Why is this needed? What is wrong with the current scheme of binding
ttys to the console?
thanks,
greg k-h
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 2/5] VT binding: Add sysfs support
2006-06-09 22:08 ` Greg KH
@ 2006-06-10 0:38 ` Antonino A. Daplas
2006-06-10 4:37 ` Greg KH
0 siblings, 1 reply; 5+ messages in thread
From: Antonino A. Daplas @ 2006-06-10 0:38 UTC (permalink / raw)
To: Greg KH
Cc: Andrew Morton, Linux Fbdev development list,
Linux Kernel Development
Greg KH wrote:
> On Fri, Jun 09, 2006 at 04:39:51PM +0800, Antonino A. Daplas wrote:
>> Add sysfs attributes for binding and unbinding VT console drivers. The
>> attributes are located in /sys/class/tty/console and are namely:
>>
>> A. backend - list registered drivers in the following format:
>>
>> "I C: Description"
>
> No, this violates the "one value per file" issue with sysfs. How do you
> know you will not overflow the buffer passed to you?
I was wondering about this. I just want a way to show what are the currently
loaded drivers, so it's a read-only attribute. It's using snprintf (though
I haven't added a check for possible overflows, should be a 2-liner). Maximum
number of lines is 16, and there are examples of this rule-breakage in the
current sysfs tree.
/sys/class/usb_host/usb_hostx/device/pools
Yes, none are valid excuses. Anyway, what would be the best way? I was
considering creating another class for vt_console, but that would entail
the creation of a new device major number just for this.
>
>> Where: I = ID number of the driver
>> C = status of the driver which can be:
>>
>> S = system driver
>> B = bound modular driver
>> U = unbound modular driver
>>
>> Description - text description of the driver
>>
>> B. bind - binds a driver to the console layer
>>
>> echo <ID> > /sys/class/tty/console/bind
>>
>> C. unbind - unbinds a driver from the console layer
>>
>> echo <ID> > /sys/class/tty/console/unbind
>>
>> The tty layer does nothing to these attributes except create them and punt all
>> requests to the VT layer.
>
> Why is this needed? What is wrong with the current scheme of binding
> ttys to the console?
>
The binding part, maybe none, but that's still debatable. It's the unbinding
feature that people are requesting. Note the longish threads on "the future
of graphics subsystem". It would also ease the life of console driver
developers, and it would stop people from pestering me on why they cannot unload
their beloved framebuffer console and drivers and go back to VGA console.
Tony
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 2/5] VT binding: Add sysfs support
2006-06-10 0:38 ` Antonino A. Daplas
@ 2006-06-10 4:37 ` Greg KH
2006-06-10 5:56 ` Antonino A. Daplas
0 siblings, 1 reply; 5+ messages in thread
From: Greg KH @ 2006-06-10 4:37 UTC (permalink / raw)
To: Antonino A. Daplas
Cc: Andrew Morton, Linux Fbdev development list,
Linux Kernel Development
On Sat, Jun 10, 2006 at 08:38:18AM +0800, Antonino A. Daplas wrote:
> Greg KH wrote:
> > On Fri, Jun 09, 2006 at 04:39:51PM +0800, Antonino A. Daplas wrote:
> >> Add sysfs attributes for binding and unbinding VT console drivers. The
> >> attributes are located in /sys/class/tty/console and are namely:
> >>
> >> A. backend - list registered drivers in the following format:
> >>
> >> "I C: Description"
> >
> > No, this violates the "one value per file" issue with sysfs. How do you
> > know you will not overflow the buffer passed to you?
>
> I was wondering about this. I just want a way to show what are the currently
> loaded drivers, so it's a read-only attribute. It's using snprintf (though
> I haven't added a check for possible overflows, should be a 2-liner). Maximum
> number of lines is 16, and there are examples of this rule-breakage in the
> current sysfs tree.
>
> /sys/class/usb_host/usb_hostx/device/pools
Ah, thanks for pointing this out. Those files should go to debugfs,
they do NOT belong in sysfs at all.
> Yes, none are valid excuses. Anyway, what would be the best way? I was
> considering creating another class for vt_console, but that would entail
> the creation of a new device major number just for this.
No, you don't need a major to create a new class in sysfs at all. Look
at usb_host for an example of that :)
And even if you did, we have loads of free major numbers now, it's not a
big deal to get a new one.
I vote for this, it would make things much easier.
> >> Where: I = ID number of the driver
> >> C = status of the driver which can be:
> >>
> >> S = system driver
> >> B = bound modular driver
> >> U = unbound modular driver
> >>
> >> Description - text description of the driver
> >>
> >> B. bind - binds a driver to the console layer
> >>
> >> echo <ID> > /sys/class/tty/console/bind
> >>
> >> C. unbind - unbinds a driver from the console layer
> >>
> >> echo <ID> > /sys/class/tty/console/unbind
> >>
> >> The tty layer does nothing to these attributes except create them and punt all
> >> requests to the VT layer.
> >
> > Why is this needed? What is wrong with the current scheme of binding
> > ttys to the console?
> >
>
> The binding part, maybe none, but that's still debatable. It's the unbinding
> feature that people are requesting. Note the longish threads on "the future
> of graphics subsystem". It would also ease the life of console driver
> developers, and it would stop people from pestering me on why they cannot unload
> their beloved framebuffer console and drivers and go back to VGA console.
Ok, I also read the 0/5 in this series which describes this in detail,
sorry for not seeing that (hint, cc: everyone on the series that one
too, so they get a bit of detail in the future.)
thanks,
greg k-h
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 2/5] VT binding: Add sysfs support
2006-06-10 4:37 ` Greg KH
@ 2006-06-10 5:56 ` Antonino A. Daplas
0 siblings, 0 replies; 5+ messages in thread
From: Antonino A. Daplas @ 2006-06-10 5:56 UTC (permalink / raw)
To: Greg KH
Cc: Andrew Morton, Linux Fbdev development list,
Linux Kernel Development
Greg KH wrote:
> On Sat, Jun 10, 2006 at 08:38:18AM +0800, Antonino A. Daplas wrote:
>> Greg KH wrote:
>>> On Fri, Jun 09, 2006 at 04:39:51PM +0800, Antonino A. Daplas wrote:
>>>> Add sysfs attributes for binding and unbinding VT console drivers. The
>>>> attributes are located in /sys/class/tty/console and are namely:
>>>>
>>>> A. backend - list registered drivers in the following format:
>>>>
>>>> "I C: Description"
>>> No, this violates the "one value per file" issue with sysfs. How do you
>>> know you will not overflow the buffer passed to you?
>> I was wondering about this. I just want a way to show what are the currently
>> loaded drivers, so it's a read-only attribute. It's using snprintf (though
>> I haven't added a check for possible overflows, should be a 2-liner). Maximum
>> number of lines is 16, and there are examples of this rule-breakage in the
>> current sysfs tree.
>>
>> /sys/class/usb_host/usb_hostx/device/pools
>
> Ah, thanks for pointing this out. Those files should go to debugfs,
> they do NOT belong in sysfs at all.
>
>> Yes, none are valid excuses. Anyway, what would be the best way? I was
>> considering creating another class for vt_console, but that would entail
>> the creation of a new device major number just for this.
>
> No, you don't need a major to create a new class in sysfs at all. Look
> at usb_host for an example of that :)
Aha, I see it now. Yes, this is exactly what I need. Thanks for the tip.
> Ok, I also read the 0/5 in this series which describes this in detail,
> sorry for not seeing that (hint, cc: everyone on the series that one
> too, so they get a bit of detail in the future.)
>
Sorry about that, slipped my mind.
Tony
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2006-06-10 5:56 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-06-09 8:39 [PATCH 2/5] VT binding: Add sysfs support Antonino A. Daplas
2006-06-09 22:08 ` Greg KH
2006-06-10 0:38 ` Antonino A. Daplas
2006-06-10 4:37 ` Greg KH
2006-06-10 5:56 ` Antonino A. Daplas
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).