通过proc查询tty

时间:2024-03-21 08:02:31
在fs/proc/proc_tty.c 中创建tty的proc的接口可以查询当前系统tty的情况
void __init proc_tty_init(void)
{
    if (!proc_mkdir("tty", NULL))
        return;
    proc_mkdir("tty/ldisc", NULL);    /* Preserved: it's userspace visible */
    /*
     * /proc/tty/driver/serial reveals the exact character counts for
     * serial links which is just too easy to abuse for inferring
     * password lengths and inter-keystroke timings during password
     * entry.
     */
    proc_tty_driver = proc_mkdir_mode("tty/driver", S_IRUSR|S_IXUSR, NULL);
    proc_create("tty/ldiscs", 0, NULL, &tty_ldiscs_proc_fops);
    proc_create("tty/drivers", 0, NULL, &proc_tty_drivers_operations);
}

会创建四个文件 ,tty/ldisc 是空文件,我们主要关注tty/drivers和 tty/driver的实现

通过tty/driver 可以查询tty的详细信息

通过proc查询tty

通过tty/drivers 可以查询概况

通过proc查询tty