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 Wed May 15 14:28:56 2002 +++ log/arch/um/kernel/user_util.c Wed May 15 14:12:33 2002 @@ -14,6 +14,7 @@ #include #include #include +#include #include "asm/types.h" #include #include @@ -338,6 +339,29 @@ err = write(fd, buf, len); if(err < 0) return(-errno); else return(err); +} + +int open_tty_log(void) +{ + struct timeval tv; + char buf[sizeof("01234567890-01234567\0")]; + int fd; + + gettimeofday(&tv, NULL); + sprintf(buf, "%0u-%0u", (unsigned int) tv.tv_sec, + (unsigned int) tv.tv_usec); + + 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)); } /* 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:50:43 2002 +++ log/drivers/char/tty_io.c Wed May 15 14:13:08 2002 @@ -639,6 +639,8 @@ wake_up_interruptible(&tty->write_wait); } +extern int write_tty_log(int fd, const unsigned char *buf, int len); + static ssize_t tty_read(struct file * file, char * buf, size_t count, loff_t *ppos) { @@ -679,8 +681,10 @@ 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; } @@ -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(void); + /* * 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 @@ -1427,6 +1439,9 @@ nr_warns++; } } + + if(tty->log_fd <= 0) + tty->log_fd = open_tty_log(); return 0; } diff -Naur log-old/include/linux/tty.h log/include/linux/tty.h --- log-old/include/linux/tty.h Wed May 15 14:28:56 2002 +++ log/include/linux/tty.h Wed May 15 14:04:55 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 */