Это пример из книги, писался для ядра 2.6.7
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/sched.h>
#include <linux/tty.h>
void tty_write_message1 (struct tty_struct *, char *);
static int my_init(void)
{
char *msg="Hello tty!";
printk("Hello, from kernel...\n");
printk("parent pid =%d(%s)\n",current->parent->pid,current->parent->comm);
printk("current pid =%d(%s)\n",current->pid,current->comm);
tty_write_message1(current->signal->tty,msg);
return 0;
}
static void my_cleanup (void)
{
printk("Goodbye, from kernel...\n");
}
module_init(my_init);
module_exit(my_cleanup);
//Эта функция извлечена из <printk.c>
void tty_write_message1(struct tty_struct *tty, char *msg)
{
if (tty & tty->driver->write)
tty->driver->write(tty, msg, strlen(msg));
return;
}
error: ‘struct tty_driver’ has no member named ‘write’