1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright (c) 2010 Werner Fink, Jiri Slaby
6 #include <linux/console.h>
7 #include <linux/kernel.h>
8 #include <linux/proc_fs.h>
9 #include <linux/seq_file.h>
10 #include <linux/tty_driver.h>
13 * This is handler for /proc/consoles
15 static int show_console_dev(struct seq_file
*m
, void *v
)
24 { CON_PRINTBUFFER
, 'p' },
28 char flags
[ARRAY_SIZE(con_flags
) + 1];
29 struct console
*con
= v
;
34 const struct tty_driver
*driver
;
36 driver
= con
->device(con
, &index
);
38 dev
= MKDEV(driver
->major
, driver
->minor_start
);
43 for (a
= 0; a
< ARRAY_SIZE(con_flags
); a
++)
44 flags
[a
] = (con
->flags
& con_flags
[a
].flag
) ?
45 con_flags
[a
].name
: ' ';
48 seq_setwidth(m
, 21 - 1);
49 seq_printf(m
, "%s%d", con
->name
, con
->index
);
51 seq_printf(m
, "%c%c%c (%s)", con
->read
? 'R' : '-',
52 con
->write
? 'W' : '-', con
->unblank
? 'U' : '-',
55 seq_printf(m
, " %4d:%d", MAJOR(dev
), MINOR(dev
));
61 static void *c_start(struct seq_file
*m
, loff_t
*pos
)
74 static void *c_next(struct seq_file
*m
, void *v
, loff_t
*pos
)
76 struct console
*con
= v
;
81 static void c_stop(struct seq_file
*m
, void *v
)
86 static const struct seq_operations consoles_op
= {
90 .show
= show_console_dev
93 static int __init
proc_consoles_init(void)
95 proc_create_seq("consoles", 0, NULL
, &consoles_op
);
98 fs_initcall(proc_consoles_init
);