How can I find which physical device /dev/console connects to?
embedded-linux, linux-device-driver, linux-kernel, tty
Solution
I think `/sys/devices/virtual/tty/console/active` is what you're looking for.
Problem
There is a device file called `/dev/console`, whose `(major,minor)` is `(5,1)`. When I boot with a serial console, it connects to my UART port as `/dev/ttyS0` does. But when I boot with serial console disabled, the `/dev/console` seems to connect to elsewhere, where `/dev/ttyS0` always connects to the same physical device, namely `UART0`. Is there any indication (like something in `/proc` or `/sys`) showing such information? I have tried there but found nothing I want. I am starting to trace the Linux kernel source to clarify their relationships. Can anyone give me some hints? When, where, how and what to determine the physical device to which `/dev/console` connects? EDIT: The latest finding is that: - the `/dev/console` is configured by `console=` of the kernel parameters, which in turn is used by `getty` to open `stdin/stdout/stderr`. If no `console=` is specified, `/dev/null` is opened as `stdin/stdout/stderr`. But I am not sure they are exactly the same with `/dev/console`, which implies `/dev/console` can have its I/O connecting to different physical devices. - The `/dev/console` can be read if a USB HID keyboard is plugged and the `console=` is not configured as UART. Therefore `/dev/console` == `/dev/null` seems to make little sense. Need more investigations.