[axlrose@ibmgentoo hello] $ sudo insmod hello.ko
[axlrose@ibmgentoo hello] $ sudo insmod hello.ko
insmod: error inserting 'hello.ko': -1 File exists
[axlrose@ibmgentoo hello] $ sudo rmmod hello
[axlrose@ibmgentoo hello] $ sudo insmod hello.ko
[axlrose@ibmgentoo hello] $ sudo insmod hello.ko
insmod: error inserting 'hello.ko': -1 File exists

现在一眼就能看出怎么回事了, -1 文件已存在,也就是说hello模块已经加载了,再次加载便得到上面的错误信息

http://oreilly.com/catalog/9780596005900/errata/9780596005900.unconfirmed
{78} Code example and 2nd paragraph;
The code example on this page returns "Invalid argument"

# ./setconsole 1
./setconsole: ioctl(stdin, TIOCLINUX): Invalid argument

Code correction: 11 is the TIOCL_SETKMSGREDIRECT cmd number

include/linux/tiocl.h:#define TIOCL_SETKMSGREDIRECT 11 /* restrict kernel
messages to a vt */

Also, drivers/char/vt.c explains TIOCLINUX, not tty_io.c
I'm still trying to figure out why it always returns EINVAL.

My kernel version is:
# uname -r
2.6.17-1.2174_FC5

在X终端下就会遇到这个错误提示,换到Ctrl + Alt + F2 --->>
# ./setconsole 2
执行insmod xxx.ko 后马上能看到printk信息,当然,setlevel 7 别忘了, cat /proc/sys/kernel/printk
能看到跟dmesg的模块输出信息

/proc/pid/fd 下面为该进程打开的文件描述符