-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
yaml --- r: 227055 b: refs/heads/master c: 23308ba h: refs/heads/master i: 227053: d29db11 227051: 5089138 227047: c6cb8f5 227039: d90c959 v: v3
- Loading branch information
Jiri Slaby
authored and
Greg Kroah-Hartman
committed
Nov 16, 2010
1 parent
75ac1d4
commit 898a829
Showing
4 changed files
with
140 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
--- | ||
refs/heads/master: 281e66057757ddf32ffe679a08f9634fa9f70a7a | ||
refs/heads/master: 23308ba54dcdb54481163bfb07dd8aeca76a7a2e |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
/* | ||
* 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; | ||
int len; | ||
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_printf(m, "%s%d%n", con->name, con->index, &len); | ||
len = 21 - len; | ||
if (len < 1) | ||
len = 1; | ||
seq_printf(m, "%*c%c%c%c (%s)", len, ' ', 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; | ||
|
||
acquire_console_sem(); | ||
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) | ||
{ | ||
release_console_sem(); | ||
} | ||
|
||
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 register_proc_consoles(void) | ||
{ | ||
proc_create("consoles", 0, NULL, &proc_consoles_operations); | ||
return 0; | ||
} | ||
module_init(register_proc_consoles); |