summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjdike <jdike>2003-08-07 18:58:40 +0000
committerjdike <jdike>2003-08-07 18:58:40 +0000
commit931c5fd7a61eef07a136025f37cc47ee1037dec8 (patch)
tree816dea870a7ec9f4e5e073ffc2bcd6cd361c573e
parent174b01a9d7aa734f99ee6abfe9aa0036a784b2af (diff)
downloaduml-history-931c5fd7a61eef07a136025f37cc47ee1037dec8.tar.gz
Made the tty logging code pluggable, so a non-UML kernel can specify its
own output routines.
-rw-r--r--arch/um/kernel/tty_log.c19
-rw-r--r--drivers/char/tty_io.c37
2 files changed, 40 insertions, 16 deletions
diff --git a/arch/um/kernel/tty_log.c b/arch/um/kernel/tty_log.c
index 9a849a7..2b1e8b0 100644
--- a/arch/um/kernel/tty_log.c
+++ b/arch/um/kernel/tty_log.c
@@ -90,14 +90,14 @@ void close_tty_log(int fd, void *tty)
close(fd);
}
-static int log_chunk(int fd, char *buf, int len)
+static int log_chunk(int fd, const char *buf, int len)
{
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);
+ missed = copy_from_user_proc(chunk, (char *) buf, try);
try -= missed;
n = write(fd, chunk, try);
if(n != try)
@@ -113,7 +113,7 @@ static int log_chunk(int fd, char *buf, int len)
return(total);
}
-int write_tty_log(int fd, char *buf, int len, void *tty, int is_read)
+int write_tty_log(int fd, const char *buf, int len, void *tty, int is_read)
{
struct timeval tv;
struct tty_log_buf data;
@@ -169,6 +169,19 @@ void log_exec(char **argv, void *tty)
}
}
+extern void register_tty_logger(int (*opener)(void *, void *),
+ int (*writer)(int, const char *, int,
+ void *, int),
+ void (*closer)(int, void *));
+
+static int register_logger(void)
+{
+ register_tty_logger(open_tty_log, write_tty_log, close_tty_log);
+ return(0);
+}
+
+__uml_initcall(register_logger);
+
static int __init set_tty_log_dir(char *name, int *add)
{
tty_log_dir = name;
diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c
index 5c98eef..8403828 100644
--- a/drivers/char/tty_io.c
+++ b/drivers/char/tty_io.c
@@ -637,8 +637,22 @@ 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,
- int direction);
+#ifdef CONFIG_TTY_LOG
+
+int (*open_log)(void *, void *) = NULL;
+int (*write_log)(int, const char *, int, void *, int) = NULL;
+void (*close_log)(int, void *) = NULL;
+
+void register_tty_logger(int (*opener)(void *, void *),
+ int (*writer)(int, const char *, int, void *, int),
+ void (*closer)(int, void *))
+{
+ open_log = opener;
+ write_log = writer;
+ close_log = closer;
+}
+
+#endif
static ssize_t tty_read(struct file * file, char * buf, size_t count,
loff_t *ppos)
@@ -683,8 +697,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, 1);
+ if((tty->log_fd >= 0) && (write_log != NULL))
+ (*write_log)(tty->log_fd, buf, i, tty, 1);
#endif
}
return i;
@@ -741,8 +755,8 @@ static inline ssize_t do_tty_write(
file->f_dentry->d_inode->i_mtime = CURRENT_TIME;
ret = written;
#ifdef CONFIG_TTY_LOG
- if(tty->log_fd >= 0)
- write_tty_log(tty->log_fd, buf - ret, ret, tty, 0);
+ if((tty->log_fd >= 0) && (write_log != NULL))
+ (*write_log)(tty->log_fd, buf - ret, ret, tty, 0);
#endif
}
up(&tty->atomic_write);
@@ -1054,8 +1068,6 @@ static void release_mem(struct tty_struct *tty, int idx)
free_tty_struct(tty);
}
-extern int close_tty_log(int fd, void *tty);
-
/*
* Even releasing the tty structures is a tricky business.. We have
* to be very careful that the structures are all released at the
@@ -1285,7 +1297,8 @@ static void release_dev(struct file * filp)
flush_scheduled_tasks();
#ifdef CONFIG_TTY_LOG
- if(tty->log_fd >= 0) close_tty_log(tty->log_fd, tty);
+ if((tty->log_fd >= 0) && (close_log != NULL))
+ (*close_log)(tty->log_fd, tty);
#endif
/*
@@ -1295,8 +1308,6 @@ static void release_dev(struct file * filp)
release_mem(tty, idx);
}
-extern int open_tty_log(void *tty, void *current_tty);
-
/*
* 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
@@ -1450,8 +1461,8 @@ init_dev_done:
}
#ifdef CONFIG_TTY_LOG
- if(tty->log_fd < 0)
- tty->log_fd = open_tty_log(tty, current->tty);
+ if((tty->log_fd < 0) && (open_log != NULL))
+ tty->log_fd = (*open_log)(tty, current->tty);
#endif
return 0;
}