mirror of
https://github.com/team-infusion-developers/android_kernel_samsung_msm8976.git
synced 2024-11-07 04:09:21 +00:00
fc42b06349
All seq_printf() users are using "%n" for calculating padding size, convert them to use seq_setwidth() / seq_pad() pair. Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> Signed-off-by: Kees Cook <keescook@chromium.org> Cc: Joe Perches <joe@perches.com> Cc: David Miller <davem@davemloft.net> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Git-commit: 652586df95e5d76b37d07a11839126dcfede1621 Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git [davidb@codeaurora.org: Resolve merge conflicts with ipv4/6 ping changes in upstream] CRs-fixed: 665291 Change-Id: Ia0416c9dbe3d80ff35f24f9c93c3543d1200a327 Signed-off-by: David Brown <davidb@codeaurora.org>
112 lines
2.2 KiB
C
112 lines
2.2 KiB
C
/*
|
|
* Copyright (c) 2010 Werner Fink, Jiri Slaby
|
|
*
|
|
* Licensed under GPLv2
|
|
*/
|
|
|
|
#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_printf(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 consoles_open(struct inode *inode, struct file *file)
|
|
{
|
|
return seq_open(file, &consoles_op);
|
|
}
|
|
|
|
static const struct file_operations proc_consoles_operations = {
|
|
.open = consoles_open,
|
|
.read = seq_read,
|
|
.llseek = seq_lseek,
|
|
.release = seq_release,
|
|
};
|
|
|
|
static int __init proc_consoles_init(void)
|
|
{
|
|
proc_create("consoles", 0, NULL, &proc_consoles_operations);
|
|
return 0;
|
|
}
|
|
module_init(proc_consoles_init);
|