mirror of
https://github.com/torvalds/linux.git
synced 2024-11-22 12:11:40 +00:00
f50a7f3d92
Based on 1 normalized pattern(s): licensed under gplv2 extracted by the scancode license scanner the SPDX license identifier GPL-2.0-only has been chosen to replace the boilerplate/reference in 99 file(s). Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Reviewed-by: Alexios Zavras <alexios.zavras@intel.com> Reviewed-by: Richard Fontana <rfontana@redhat.com> Reviewed-by: Allison Randal <allison@lohutok.net> Reviewed-by: Steve Winslow <swinslow@gmail.com> Cc: linux-spdx@vger.kernel.org Link: https://lkml.kernel.org/r/20190528170027.163048684@linutronix.de Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
99 lines
1.9 KiB
C
99 lines
1.9 KiB
C
// SPDX-License-Identifier: GPL-2.0-only
|
|
/*
|
|
* Copyright (c) 2010 Werner Fink, Jiri Slaby
|
|
*/
|
|
|
|
#include <linux/console.h>
|
|
#include <linux/kernel.h>
|
|
#include <linux/proc_fs.h>
|
|
#include <linux/seq_file.h>
|
|
#include <linux/tty_driver.h>
|
|
|
|
/*
|
|
* This is handler for /proc/consoles
|
|
*/
|
|
static int show_console_dev(struct seq_file *m, void *v)
|
|
{
|
|
static const struct {
|
|
short flag;
|
|
char name;
|
|
} con_flags[] = {
|
|
{ CON_ENABLED, 'E' },
|
|
{ CON_CONSDEV, 'C' },
|
|
{ CON_BOOT, 'B' },
|
|
{ CON_PRINTBUFFER, 'p' },
|
|
{ CON_BRL, 'b' },
|
|
{ CON_ANYTIME, 'a' },
|
|
};
|
|
char flags[ARRAY_SIZE(con_flags) + 1];
|
|
struct console *con = v;
|
|
unsigned int a;
|
|
dev_t dev = 0;
|
|
|
|
if (con->device) {
|
|
const struct tty_driver *driver;
|
|
int index;
|
|
driver = con->device(con, &index);
|
|
if (driver) {
|
|
dev = MKDEV(driver->major, driver->minor_start);
|
|
dev += index;
|
|
}
|
|
}
|
|
|
|
for (a = 0; a < ARRAY_SIZE(con_flags); a++)
|
|
flags[a] = (con->flags & con_flags[a].flag) ?
|
|
con_flags[a].name : ' ';
|
|
flags[a] = 0;
|
|
|
|
seq_setwidth(m, 21 - 1);
|
|
seq_printf(m, "%s%d", con->name, con->index);
|
|
seq_pad(m, ' ');
|
|
seq_printf(m, "%c%c%c (%s)", con->read ? 'R' : '-',
|
|
con->write ? 'W' : '-', con->unblank ? 'U' : '-',
|
|
flags);
|
|
if (dev)
|
|
seq_printf(m, " %4d:%d", MAJOR(dev), MINOR(dev));
|
|
|
|
seq_putc(m, '\n');
|
|
return 0;
|
|
}
|
|
|
|
static void *c_start(struct seq_file *m, loff_t *pos)
|
|
{
|
|
struct console *con;
|
|
loff_t off = 0;
|
|
|
|
console_lock();
|
|
for_each_console(con)
|
|
if (off++ == *pos)
|
|
break;
|
|
|
|
return con;
|
|
}
|
|
|
|
static void *c_next(struct seq_file *m, void *v, loff_t *pos)
|
|
{
|
|
struct console *con = v;
|
|
++*pos;
|
|
return con->next;
|
|
}
|
|
|
|
static void c_stop(struct seq_file *m, void *v)
|
|
{
|
|
console_unlock();
|
|
}
|
|
|
|
static const struct seq_operations consoles_op = {
|
|
.start = c_start,
|
|
.next = c_next,
|
|
.stop = c_stop,
|
|
.show = show_console_dev
|
|
};
|
|
|
|
static int __init proc_consoles_init(void)
|
|
{
|
|
proc_create_seq("consoles", 0, NULL, &consoles_op);
|
|
return 0;
|
|
}
|
|
fs_initcall(proc_consoles_init);
|