diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2011-01-07 17:39:20 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2011-01-07 17:39:20 -0500 |
commit | 56b85f32d530d09d6805488ad00775d4e0e3baab (patch) | |
tree | e7fbe69e338ef775d3b2dd822aa915d259b4bc94 /fs | |
parent | 3e5b08cbbf78bedd316904ab0cf3b27119433ee5 (diff) | |
parent | 568389c257fa7d74ce36c2f78bad31965fded4cf (diff) |
Merge branch 'tty-next' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty-2.6
* 'tty-next' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty-2.6: (36 commits)
serial: apbuart: Fixup apbuart_console_init()
TTY: Add tty ioctl to figure device node of the system console.
tty: add 'active' sysfs attribute to tty0 and console device
drivers: serial: apbuart: Handle OF failures gracefully
Serial: Avoid unbalanced IRQ wake disable during resume
tty: fix typos/errors in tty_driver.h comments
pch_uart : fix warnings for 64bit compile
8250: fix uninitialized FIFOs
ip2: fix compiler warning on ip2main_pci_tbl
specialix: fix compiler warning on specialix_pci_tbl
rocket: fix compiler warning on rocket_pci_ids
8250: add a UPIO_DWAPB32 for 32 bit accesses
8250: use container_of() instead of casting
serial: omap-serial: Add support for kernel debugger
serial: fix pch_uart kconfig & build
drivers: char: hvc: add arm JTAG DCC console support
RS485 documentation: add 16C950 UART description
serial: ifx6x60: fix memory leak
serial: ifx6x60: free IRQ on error
Serial: EG20T: add PCH_UART driver
...
Fixed up conflicts in drivers/serial/apbuart.c with evil merge that
makes the code look fairly sane (unlike either side).
Diffstat (limited to 'fs')
-rw-r--r-- | fs/compat_ioctl.c | 1 | ||||
-rw-r--r-- | fs/proc/Makefile | 1 | ||||
-rw-r--r-- | fs/proc/proc_console.c | 114 |
3 files changed, 116 insertions, 0 deletions
diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c index 175736c282ab..61abb638b4bf 100644 --- a/fs/compat_ioctl.c +++ b/fs/compat_ioctl.c | |||
@@ -836,6 +836,7 @@ COMPATIBLE_IOCTL(TCSETSW) | |||
836 | COMPATIBLE_IOCTL(TCSETSF) | 836 | COMPATIBLE_IOCTL(TCSETSF) |
837 | COMPATIBLE_IOCTL(TIOCLINUX) | 837 | COMPATIBLE_IOCTL(TIOCLINUX) |
838 | COMPATIBLE_IOCTL(TIOCSBRK) | 838 | COMPATIBLE_IOCTL(TIOCSBRK) |
839 | COMPATIBLE_IOCTL(TIOCGDEV) | ||
839 | COMPATIBLE_IOCTL(TIOCCBRK) | 840 | COMPATIBLE_IOCTL(TIOCCBRK) |
840 | COMPATIBLE_IOCTL(TIOCGSID) | 841 | COMPATIBLE_IOCTL(TIOCGSID) |
841 | COMPATIBLE_IOCTL(TIOCGICOUNT) | 842 | COMPATIBLE_IOCTL(TIOCGICOUNT) |
diff --git a/fs/proc/Makefile b/fs/proc/Makefile index 2758e2afc518..288a49e098bf 100644 --- a/fs/proc/Makefile +++ b/fs/proc/Makefile | |||
@@ -15,6 +15,7 @@ proc-y += devices.o | |||
15 | proc-y += interrupts.o | 15 | proc-y += interrupts.o |
16 | proc-y += loadavg.o | 16 | proc-y += loadavg.o |
17 | proc-y += meminfo.o | 17 | proc-y += meminfo.o |
18 | proc-y += proc_console.o | ||
18 | proc-y += stat.o | 19 | proc-y += stat.o |
19 | proc-y += uptime.o | 20 | proc-y += uptime.o |
20 | proc-y += version.o | 21 | proc-y += version.o |
diff --git a/fs/proc/proc_console.c b/fs/proc/proc_console.c new file mode 100644 index 000000000000..8a707609f528 --- /dev/null +++ b/fs/proc/proc_console.c | |||
@@ -0,0 +1,114 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2010 Werner Fink, Jiri Slaby | ||
3 | * | ||
4 | * Licensed under GPLv2 | ||
5 | */ | ||
6 | |||
7 | #include <linux/console.h> | ||
8 | #include <linux/kernel.h> | ||
9 | #include <linux/proc_fs.h> | ||
10 | #include <linux/seq_file.h> | ||
11 | #include <linux/tty_driver.h> | ||
12 | |||
13 | /* | ||
14 | * This is handler for /proc/consoles | ||
15 | */ | ||
16 | static int show_console_dev(struct seq_file *m, void *v) | ||
17 | { | ||
18 | static const struct { | ||
19 | short flag; | ||
20 | char name; | ||
21 | } con_flags[] = { | ||
22 | { CON_ENABLED, 'E' }, | ||
23 | { CON_CONSDEV, 'C' }, | ||
24 | { CON_BOOT, 'B' }, | ||
25 | { CON_PRINTBUFFER, 'p' }, | ||
26 | { CON_BRL, 'b' }, | ||
27 | { CON_ANYTIME, 'a' }, | ||
28 | }; | ||
29 | char flags[ARRAY_SIZE(con_flags) + 1]; | ||
30 | struct console *con = v; | ||
31 | unsigned int a; | ||
32 | int len; | ||
33 | dev_t dev = 0; | ||
34 | |||
35 | if (con->device) { | ||
36 | const struct tty_driver *driver; | ||
37 | int index; | ||
38 | driver = con->device(con, &index); | ||
39 | if (driver) { | ||
40 | dev = MKDEV(driver->major, driver->minor_start); | ||
41 | dev += index; | ||
42 | } | ||
43 | } | ||
44 | |||
45 | for (a = 0; a < ARRAY_SIZE(con_flags); a++) | ||
46 | flags[a] = (con->flags & con_flags[a].flag) ? | ||
47 | con_flags[a].name : ' '; | ||
48 | flags[a] = 0; | ||
49 | |||
50 | seq_printf(m, "%s%d%n", con->name, con->index, &len); | ||
51 | len = 21 - len; | ||
52 | if (len < 1) | ||
53 | len = 1; | ||
54 | seq_printf(m, "%*c%c%c%c (%s)", len, ' ', con->read ? 'R' : '-', | ||
55 | con->write ? 'W' : '-', con->unblank ? 'U' : '-', | ||
56 | flags); | ||
57 | if (dev) | ||
58 | seq_printf(m, " %4d:%d", MAJOR(dev), MINOR(dev)); | ||
59 | |||
60 | seq_printf(m, "\n"); | ||
61 | |||
62 | return 0; | ||
63 | } | ||
64 | |||
65 | static void *c_start(struct seq_file *m, loff_t *pos) | ||
66 | { | ||
67 | struct console *con; | ||
68 | loff_t off = 0; | ||
69 | |||
70 | acquire_console_sem(); | ||
71 | for_each_console(con) | ||
72 | if (off++ == *pos) | ||
73 | break; | ||
74 | |||
75 | return con; | ||
76 | } | ||
77 | |||
78 | static void *c_next(struct seq_file *m, void *v, loff_t *pos) | ||
79 | { | ||
80 | struct console *con = v; | ||
81 | ++*pos; | ||
82 | return con->next; | ||
83 | } | ||
84 | |||
85 | static void c_stop(struct seq_file *m, void *v) | ||
86 | { | ||
87 | release_console_sem(); | ||
88 | } | ||
89 | |||
90 | static const struct seq_operations consoles_op = { | ||
91 | .start = c_start, | ||
92 | .next = c_next, | ||
93 | .stop = c_stop, | ||
94 | .show = show_console_dev | ||
95 | }; | ||
96 | |||
97 | static int consoles_open(struct inode *inode, struct file *file) | ||
98 | { | ||
99 | return seq_open(file, &consoles_op); | ||
100 | } | ||
101 | |||
102 | static const struct file_operations proc_consoles_operations = { | ||
103 | .open = consoles_open, | ||
104 | .read = seq_read, | ||
105 | .llseek = seq_lseek, | ||
106 | .release = seq_release, | ||
107 | }; | ||
108 | |||
109 | static int register_proc_consoles(void) | ||
110 | { | ||
111 | proc_create("consoles", 0, NULL, &proc_consoles_operations); | ||
112 | return 0; | ||
113 | } | ||
114 | module_init(register_proc_consoles); | ||