From: Ben Gras Date: Fri, 22 Jul 2005 18:24:17 +0000 (+0000) Subject: Nits here and there. Made log device buffer messages again. X-Git-Tag: v3.1.0~570 X-Git-Url: http://zhaoyanbai.com/repos/icons/debian/static/tz-art.htm?a=commitdiff_plain;h=d09f170abc29ed6243aab21f6ce74b2a792ec37c;p=minix.git Nits here and there. Made log device buffer messages again. --- diff --git a/drivers/log/Makefile b/drivers/log/Makefile index bc6de0779..aae039630 100644 --- a/drivers/log/Makefile +++ b/drivers/log/Makefile @@ -23,7 +23,7 @@ LIBDRIVER = $d/libdriver/driver.o all build: $(DRIVER) $(DRIVER): $(OBJ) $(LIBDRIVER) $(CC) -o $@ $(LDFLAGS) $(OBJ) $(LIBDRIVER) $(LIBS) - install -S 64w $(DRIVER) + install -S 4kb $(DRIVER) $(LIBDRIVER): cd $d/libdriver && $(MAKE) diff --git a/drivers/log/diag.c b/drivers/log/diag.c index 524a4e79e..2cce4157a 100644 --- a/drivers/log/diag.c +++ b/drivers/log/diag.c @@ -48,14 +48,14 @@ message *m; /* notification message */ i=0; while (bytes > 0) { print_buf[i] = kmess.km_buf[(r%KMESS_BUF_SIZE)]; - log_putc( kmess.km_buf[(r%KMESS_BUF_SIZE)] ); bytes --; r ++; i ++; } /* Now terminate the new message and print it. */ print_buf[i] = 0; - printf(print_buf); + printf("%s", print_buf); + log_append(print_buf, i); } /* Almost done, store 'next' so that we can determine what part of the @@ -82,7 +82,7 @@ PUBLIC int do_diagnostics(message *m) int count; char c; int i = 0; - static char diagbuf[1024]; + static char diagbuf[10240]; /* Forward the message to the TTY driver. Inform the TTY driver about the * original sender, so that it knows where the buffer to be printed is. @@ -97,26 +97,14 @@ PUBLIC int do_diagnostics(message *m) */ src = (vir_bytes) m->DIAG_PRINT_BUF; count = m->DIAG_BUF_COUNT; - while (count > 0) { + while (count > 0 && i < sizeof(diagbuf)-1) { if (sys_datacopy(proc_nr, src, SELF, (vir_bytes) &c, 1) != OK) break; /* stop copying on error */ - log_putc(c); /* accumulate character */ src ++; count --; + diagbuf[i++] = c; } + log_append(diagbuf, i); return result; } - - -/*===========================================================================* - * log_putc * - *===========================================================================*/ -PUBLIC void log_putc(c) -int c; /* char to be added to diag buffer */ -{ - -} - - - diff --git a/drivers/log/log.c b/drivers/log/log.c index fecf19212..da2054873 100644 --- a/drivers/log/log.c +++ b/drivers/log/log.c @@ -112,8 +112,13 @@ subwrite(struct logdevice *log, int count, int proc_nr, vir_bytes user_vir) count = LOG_SIZE - log->log_write; buf = log->log_buffer + log->log_write; - if((r=sys_vircopy(proc_nr,D,user_vir, SELF,D,(int)buf, count)) != OK) - return r; + if(proc_nr == SELF) { + memcpy(buf, (char *) user_vir, count); + } + else { + if((r=sys_vircopy(proc_nr,D,user_vir, SELF,D,(int)buf, count)) != OK) + return r; + } LOGINC(log->log_write, count); log->log_size += count; @@ -160,6 +165,25 @@ subwrite(struct logdevice *log, int count, int proc_nr, vir_bytes user_vir) return count; } +/*===========================================================================* + * log_append * + *===========================================================================*/ +PUBLIC void +log_append(char *buf, int count) +{ + int w = 0, skip = 0; + + if(count < 1) return; + if(count > LOG_SIZE) skip = count - LOG_SIZE; + count -= skip; + buf += skip; + w = subwrite(&logdevices[0], count, SELF, (vir_bytes) buf); + + if(w > 0 && w < count) + subwrite(&logdevices[0], count-w, SELF, (vir_bytes) buf+w); + return; +} + /*===========================================================================* * subread * *===========================================================================*/ @@ -224,9 +248,6 @@ unsigned nr_req; /* length of request vector */ /* There's already someone hanging to read, or * no real I/O requested. */ -#if LOG_DEBUG - printf("someone (%d) is already blocking\n", log->log_proc_nr); -#endif return(OK); } @@ -345,7 +366,7 @@ message *m_ptr; } /*============================================================================* - * log_select * + * log_other * *============================================================================*/ PRIVATE int log_other(dp, m_ptr) struct driver *dp; diff --git a/drivers/log/log.h b/drivers/log/log.h index 91ab3aee2..ff58f05b3 100644 --- a/drivers/log/log.h +++ b/drivers/log/log.h @@ -31,6 +31,5 @@ struct logdevice { _PROTOTYPE( void kputc, (int c) ); _PROTOTYPE( int do_new_kmess, (message *m) ); _PROTOTYPE( int do_diagnostics, (message *m) ); -_PROTOTYPE( void log_putc, (int c) ); - +_PROTOTYPE( void log_append, (char *buf, int len) );