~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/fs/proc/consoles.c

Version: ~ [ linux-5.13-rc7 ] ~ [ linux-5.12.12 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.45 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.127 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.195 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.237 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.273 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.273 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.18.140 ] ~ [ linux-3.16.85 ] ~ [ linux-3.14.79 ] ~ [ linux-3.12.74 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  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         dev_t dev = 0;
 33 
 34         if (con->device) {
 35                 const struct tty_driver *driver;
 36                 int index;
 37                 driver = con->device(con, &index);
 38                 if (driver) {
 39                         dev = MKDEV(driver->major, driver->minor_start);
 40                         dev += index;
 41                 }
 42         }
 43 
 44         for (a = 0; a < ARRAY_SIZE(con_flags); a++)
 45                 flags[a] = (con->flags & con_flags[a].flag) ?
 46                         con_flags[a].name : ' ';
 47         flags[a] = 0;
 48 
 49         seq_setwidth(m, 21 - 1);
 50         seq_printf(m, "%s%d", con->name, con->index);
 51         seq_pad(m, ' ');
 52         seq_printf(m, "%c%c%c (%s)", con->read ? 'R' : '-',
 53                         con->write ? 'W' : '-', con->unblank ? 'U' : '-',
 54                         flags);
 55         if (dev)
 56                 seq_printf(m, " %4d:%d", MAJOR(dev), MINOR(dev));
 57 
 58         seq_putc(m, '\n');
 59         return 0;
 60 }
 61 
 62 static void *c_start(struct seq_file *m, loff_t *pos)
 63 {
 64         struct console *con;
 65         loff_t off = 0;
 66 
 67         console_lock();
 68         for_each_console(con)
 69                 if (off++ == *pos)
 70                         break;
 71 
 72         return con;
 73 }
 74 
 75 static void *c_next(struct seq_file *m, void *v, loff_t *pos)
 76 {
 77         struct console *con = v;
 78         ++*pos;
 79         return con->next;
 80 }
 81 
 82 static void c_stop(struct seq_file *m, void *v)
 83 {
 84         console_unlock();
 85 }
 86 
 87 static const struct seq_operations consoles_op = {
 88         .start  = c_start,
 89         .next   = c_next,
 90         .stop   = c_stop,
 91         .show   = show_console_dev
 92 };
 93 
 94 static int __init proc_consoles_init(void)
 95 {
 96         proc_create_seq("consoles", 0, NULL, &consoles_op);
 97         return 0;
 98 }
 99 fs_initcall(proc_consoles_init);
100 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp