2 * Copyright (c) 2010 Werner Fink, Jiri Slaby
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>
14 * This is handler for /proc/consoles
16 static int show_console_dev(struct seq_file
*m
, void *v
)
25 { CON_PRINTBUFFER
, 'p' },
29 char flags
[ARRAY_SIZE(con_flags
) + 1];
30 struct console
*con
= v
;
35 const struct tty_driver
*driver
;
37 driver
= con
->device(con
, &index
);
39 dev
= MKDEV(driver
->major
, driver
->minor_start
);
44 for (a
= 0; a
< ARRAY_SIZE(con_flags
); a
++)
45 flags
[a
] = (con
->flags
& con_flags
[a
].flag
) ?
46 con_flags
[a
].name
: ' ';
49 seq_setwidth(m
, 21 - 1);
50 seq_printf(m
, "%s%d", con
->name
, con
->index
);
52 seq_printf(m
, "%c%c%c (%s)", con
->read
? 'R' : '-',
53 con
->write
? 'W' : '-', con
->unblank
? 'U' : '-',
56 seq_printf(m
, " %4d:%d", MAJOR(dev
), MINOR(dev
));
62 static void *c_start(struct seq_file
*m
, loff_t
*pos
)
75 static void *c_next(struct seq_file
*m
, void *v
, loff_t
*pos
)
77 struct console
*con
= v
;
82 static void c_stop(struct seq_file
*m
, void *v
)
87 static const struct seq_operations consoles_op
= {
91 .show
= show_console_dev
94 static int consoles_open(struct inode
*inode
, struct file
*file
)
96 return seq_open(file
, &consoles_op
);
99 static const struct file_operations proc_consoles_operations
= {
100 .open
= consoles_open
,
103 .release
= seq_release
,
106 static int __init
proc_consoles_init(void)
108 proc_create("consoles", 0, NULL
, &proc_consoles_operations
);
111 fs_initcall(proc_consoles_init
);