diff -Naur log-old/arch/um/kernel/user_util.c log/arch/um/kernel/user_util.c --- log-old/arch/um/kernel/user_util.c Sun Apr 28 20:42:36 2002 +++ log/arch/um/kernel/user_util.c Wed May 8 11:26:06 2002 @@ -340,6 +340,26 @@ else return(err); } +int open_tty_log(char *buf) +{ + int fd, i; + + for(i = 0; i < strlen(buf); i++){ + if(buf[i] == '/') buf[i] = '-'; + } + fd = open(buf, O_RDWR | O_APPEND | O_CREAT, 0644); + if(fd < 0){ + printk("open_tty_log : couldn't open '%s', errno = %d\n", + buf, errno); + } + return(fd); +} + +int write_tty_log(int fd, char *buf, int len) +{ + return(write(fd, buf, len)); +} + /* * Overrides for Emacs so that we follow Linus's tabbing style. * Emacs will notice this stuff at the end of the file and automatically diff -Naur log-old/drivers/char/tty_io.c log/drivers/char/tty_io.c --- log-old/drivers/char/tty_io.c Mon Feb 25 12:59:15 2002 +++ log/drivers/char/tty_io.c Wed May 8 11:44:41 2002 @@ -679,11 +679,15 @@ else i = -EIO; unlock_kernel(); - if (i > 0) + if (i > 0){ inode->i_atime = CURRENT_TIME; + if(tty->log_fd > 0) write_tty_log(tty->log_fd, buf, i); + } return i; } +extern int write_tty_log(int fd, const unsigned char *buf, int len); + /* * Split writes up in sane blocksizes to avoid * denial-of-service type attacks @@ -734,6 +738,7 @@ if (written) { file->f_dentry->d_inode->i_mtime = CURRENT_TIME; ret = written; + if(tty->log_fd > 0) write_tty_log(tty->log_fd, buf - ret, ret); } up(&tty->atomic_write); return ret; @@ -974,6 +979,7 @@ } tty->count++; tty->driver = *driver; /* N.B. why do this every time?? */ + tty->log_fd = -1; success: *ret_tty = tty; @@ -1041,6 +1047,8 @@ free_tty_struct(tty); } +extern int close(int fd); + /* * Even releasing the tty structures is a tricky business.. We have * to be very careful that the structures are all released at the @@ -1269,6 +1277,8 @@ run_task_queue(&tq_timer); flush_scheduled_tasks(); + if(tty->log_fd > 0) close(tty->log_fd); + /* * The release_mem function takes care of the details of clearing * the slots and preserving the termios structure. @@ -1276,6 +1286,8 @@ release_mem(tty, idx); } +extern int open_tty_log(char *buf); + /* * tty_open and tty_release keep up the tty count that contains the * number of opens done on a tty. We cannot use the inode-count, as @@ -1426,6 +1438,11 @@ tty_name(tty, buf), TTY_NUMBER(tty)); nr_warns++; } + } + + if(tty->log_fd <= 0){ + tty_name(tty, buf); + tty->log_fd = open_tty_log(buf); } return 0; } diff -Naur log-old/include/linux/tty.h log/include/linux/tty.h --- log-old/include/linux/tty.h Wed May 8 10:33:38 2002 +++ log/include/linux/tty.h Wed May 8 11:05:34 2002 @@ -309,6 +309,7 @@ spinlock_t read_lock; /* If the tty has a pending do_SAK, queue it here - akpm */ struct tq_struct SAK_tq; + int log_fd; }; /* tty magic number */