- 论坛徽章:
- 36
|
改过后的这块代码为:- static void write_msg(struct console *con, const char *msg, unsigned int len)
- {
- #if USE_SYS_CALL
- unsigned long flags;
- mm_segment_t old_fs;
-
- // local_irq_save(flags);
- old_fs = get_fs();
- set_fs(KERNEL_DS);
- sys_write(np.pty_fd, msg, len);
- set_fs(old_fs);
-
- // local_irq_restore(flags);
- #else
- unsigned long flags;
- ssize_t ret = -EBADF;
- mm_segment_t old_fs;
-
- if (np.pty_file) {
- local_irq_save(flags);
-
- old_fs = get_fs();
- set_fs(KERNEL_DS);
-
- loff_t pos = np.pty_file->f_pos;
- ret = vfs_write(np.pty_file, msg, len, &pos);
- np.pty_file->f_pos = pos;
-
- set_fs(old_fs);
-
- // local_irq_restore(flags);
- }
- #endif
- }
复制代码 加载模块情况为
[root@localhost ~]# ptyfile:/dev/pts/2
np.pty_file:d59e3780
open file: 0
BUG: sleeping function called from invalid context at include/asm/uaccess_32.h:512
in_atomic():0, irqs_disabled():1
Pid: 6590, comm: insmod Not tainted 2.6.24.4 #2
[<c01259f8>] __might_sleep+0xa4/0xa9
[<c01ec615>] copy_from_user+0x2d/0x60
[<c02284a7>] tty_write+0x132/0x1c7
[<c022c585>] write_chan+0x0/0x1b3
[<c017389a>] vfs_write+0xac/0x12c
[<e0a0a04a>] write_msg+0x4a/0x6f [ptyconsole]
[<e0a0a000>] write_msg+0x0/0x6f [ptyconsole]
[<c01289ba>] __call_console_drivers+0x51/0x5b
[<c0128ad7>] call_console_drivers+0xb2/0xd4
[<c01290f4>] release_console_sem+0x70/0xb0
[<e0a0a126>] init_ptyconsole+0x40/0x54 [ptyconsole]
[<c01461df>] sys_init_module+0x91/0x11b
[<c0104dc6>] sysenter_past_esp+0x5f/0x85
=======================
ptyconsole: network logging started |
|