printk
In Section 1.2.1.2, I said that X and kernel module programming don't mix. That's true for developing kernel modules, but in actual use, you want to be able to send messages to whichever tty[1] the command to load the module came from.
The way this is done is by using current
, a pointer to the currently running task, to get the current
task's tty
structure. Then, we look inside that tty
structure to find a
pointer to a string write function, which we use to write a string to the tty.
[1] | Teletype, originally a combination keyboard-printer used to communicate with a Unix system, and today an abstraction for the text stream used for a Unix program, whether it's a physical terminal, an xterm on an X display, a network connection used with telnet, etc. |