summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjdike <jdike>2003-02-02 18:13:17 +0000
committerjdike <jdike>2003-02-02 18:13:17 +0000
commit3abb85285d93c86f9e349cecbbe0d1ae1dc3a782 (patch)
tree0919779c997387a7f209f3bfc98275e7ab0bef6f
parent774981bc45f03d85fd02764fd1d0970348556d43 (diff)
downloaduml-history-3abb85285d93c86f9e349cecbbe0d1ae1dc3a782.tar.gz
Added timestamps and direction flags to the tty log records.
-rw-r--r--arch/um/kernel/tty_log.c43
-rw-r--r--drivers/char/tty_io.c8
2 files changed, 34 insertions, 17 deletions
diff --git a/arch/um/kernel/tty_log.c b/arch/um/kernel/tty_log.c
index 56bb709..62b6d89 100644
--- a/arch/um/kernel/tty_log.c
+++ b/arch/um/kernel/tty_log.c
@@ -26,10 +26,16 @@ static int tty_log_fd = -1;
#define TTY_LOG_CLOSE 2
#define TTY_LOG_WRITE 3
+#define TTY_READ 1
+#define TTY_WRITE 2
+
struct tty_log_buf {
int what;
unsigned long tty;
int len;
+ int direction;
+ unsigned long sec;
+ unsigned long usec;
};
int open_tty_log(void *tty, void *current_tty)
@@ -39,16 +45,19 @@ int open_tty_log(void *tty, void *current_tty)
char buf[strlen(tty_log_dir) + sizeof("01234567890-01234567\0")];
int fd;
+ gettimeofday(&tv, NULL);
if(tty_log_fd != -1){
data = ((struct tty_log_buf) { .what = TTY_LOG_OPEN,
.tty = (unsigned long) tty,
- .len = sizeof(current_tty) });
+ .len = sizeof(current_tty),
+ .direction = 0,
+ .sec = tv.tv_sec,
+ .usec = tv.tv_usec } );
write(tty_log_fd, &data, sizeof(data));
write(tty_log_fd, &current_tty, data.len);
return(tty_log_fd);
}
- gettimeofday(&tv, NULL);
sprintf(buf, "%s/%0u-%0u", tty_log_dir, (unsigned int) tv.tv_sec,
(unsigned int) tv.tv_usec);
@@ -64,40 +73,45 @@ int open_tty_log(void *tty, void *current_tty)
void close_tty_log(int fd, void *tty)
{
struct tty_log_buf data;
+ struct timeval tv;
if(tty_log_fd != -1){
+ gettimeofday(&tv, NULL);
data = ((struct tty_log_buf) { .what = TTY_LOG_CLOSE,
.tty = (unsigned long) tty,
- .len = 0 });
+ .len = 0,
+ .direction = 0,
+ .sec = tv.tv_sec,
+ .usec = tv.tv_usec } );
write(tty_log_fd, &data, sizeof(data));
return;
}
close(fd);
}
-static int write_tty_log_chunk(int fd, char *buf, int len, void *tty)
+int write_tty_log(int fd, char *buf, int len, void *tty, int is_read)
{
+ struct timeval tv;
struct tty_log_buf data;
+ int total = 0, try, missed, n, direction;
+ char chunk[64];
if(fd == tty_log_fd){
+ gettimeofday(&tv, NULL);
+ direction = is_read ? TTY_READ : TTY_WRITE;
data = ((struct tty_log_buf) { .what = TTY_LOG_WRITE,
.tty = (unsigned long) tty,
- .len = len });
+ .len = len,
+ .direction = direction,
+ .sec = tv.tv_sec,
+ .usec = tv.tv_usec } );
write(tty_log_fd, &data, sizeof(data));
}
- return(write(fd, buf, len));
-}
-
-int write_tty_log(int fd, char *buf, int len, void *tty)
-{
- int total = 0, try, missed, n;
- char chunk[64];
-
while(len > 0){
try = (len > sizeof(chunk)) ? sizeof(chunk) : len;
missed = copy_from_user_proc(chunk, buf, try);
try -= missed;
- n = write_tty_log_chunk(fd, chunk, try, tty);
+ n = write(fd, chunk, try);
if(n != try)
return(-errno);
if(missed != 0)
@@ -105,6 +119,7 @@ int write_tty_log(int fd, char *buf, int len, void *tty)
len -= try;
total += try;
+ buf += try;
}
return(total);
}
diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c
index 45bfc53..d006678 100644
--- a/drivers/char/tty_io.c
+++ b/drivers/char/tty_io.c
@@ -635,7 +635,8 @@ void start_tty(struct tty_struct *tty)
wake_up_interruptible(&tty->write_wait);
}
-extern int write_tty_log(int fd, const unsigned char *buf, int len, void *tty);
+extern int write_tty_log(int fd, const unsigned char *buf, int len, void *tty,
+ int direction);
static ssize_t tty_read(struct file * file, char * buf, size_t count,
loff_t *ppos)
@@ -680,7 +681,8 @@ static ssize_t tty_read(struct file * file, char * buf, size_t count,
if (i > 0){
inode->i_atime = CURRENT_TIME;
#ifdef CONFIG_TTY_LOG
- if(tty->log_fd >= 0) write_tty_log(tty->log_fd, buf, i, tty);
+ if(tty->log_fd >= 0)
+ write_tty_log(tty->log_fd, buf, i, tty, 1);
#endif
}
return i;
@@ -738,7 +740,7 @@ static inline ssize_t do_tty_write(
ret = written;
#ifdef CONFIG_TTY_LOG
if(tty->log_fd >= 0)
- write_tty_log(tty->log_fd, buf - ret, ret, tty);
+ write_tty_log(tty->log_fd, buf - ret, ret, tty, 0);
#endif
}
up(&tty->atomic_write);