From: Ben Gras Date: Tue, 18 Oct 2005 10:34:54 +0000 (+0000) Subject: printf() by kernel and servers now send messages to an array of processes, X-Git-Tag: v3.1.2a~615 X-Git-Url: http://zhaoyanbai.com/repos/README?a=commitdiff_plain;h=ea75918df18b396076c47f55f69647159d391b61;p=minix.git printf() by kernel and servers now send messages to an array of processes, OUTPUT_PROCS_ARRAY in , in that order, terminated by NONE. log no longer forwards messages to tty itself. This leads to less funny loops and more robust debug-message handling. Also the list of processes receiving messages can easily be changed around or disabled by editing the array (e.g. disable it by changing the array to { NONE }.). --- diff --git a/drivers/log/Makefile b/drivers/log/Makefile index aae039630..8da0e46cb 100644 --- a/drivers/log/Makefile +++ b/drivers/log/Makefile @@ -29,8 +29,8 @@ $(LIBDRIVER): cd $d/libdriver && $(MAKE) # install with other drivers -install: /usr/sbin/$(DRIVER) -/usr/sbin/$(DRIVER): $(DRIVER) +install: /sbin/$(DRIVER) +/sbin/$(DRIVER): $(DRIVER) install -o root -cs $? $@ # clean up local files diff --git a/drivers/log/diag.c b/drivers/log/diag.c index 3776db969..7158678b7 100644 --- a/drivers/log/diag.c +++ b/drivers/log/diag.c @@ -91,7 +91,6 @@ PUBLIC int do_diagnostics(message *m) * user. It also saves a copy in a local buffer so that messages can be * reviewed at a later time. */ - int result; int proc_nr; vir_bytes src; int count; @@ -99,13 +98,9 @@ PUBLIC int do_diagnostics(message *m) int i = 0; 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. - * The message type, DIAGNOSTICS, remains the same. - */ + /* Change SELF to actual process number. */ if ((proc_nr = m->DIAG_PROC_NR) == SELF) m->DIAG_PROC_NR = proc_nr = m->m_source; - result = _sendrec(TTY_PROC_NR, m); /* Now also make a copy for the private buffer at the LOG server, so * that the messages can be reviewed at a later time. @@ -121,5 +116,5 @@ PUBLIC int do_diagnostics(message *m) } log_append(diagbuf, i); - return result; + return OK; } diff --git a/include/minix/config.h b/include/minix/config.h index 81985ac9e..afe8f342e 100755 --- a/include/minix/config.h +++ b/include/minix/config.h @@ -85,11 +85,16 @@ #define ENABLE_BINCOMPAT 0 /* for binaries using obsolete calls */ #define ENABLE_SRCCOMPAT 0 /* for sources using obsolete calls */ -/* Which process should receive diagnostics from the kernel and system? +/* Which processes should receive diagnostics from the kernel and system? * Directly sending it to TTY only displays the output. Sending it to the * log driver will cause the diagnostics to be buffered and displayed. + * Messages are sent by src/lib/sysutil/kputc.c to these processes, in + * the order of this array, which must be terminated by NONE. This is used + * by drivers and servers that printf(). + * The kernel does this for its own kprintf() in kernel/utility.c, also using + * this array, but a slightly different mechanism. */ -#define OUTPUT_PROC_NR LOG_PROC_NR /* TTY_PROC_NR or LOG_PROC_NR */ +#define OUTPUT_PROCS_ARRAY { TTY_PROC_NR, LOG_PROC_NR, NONE } /* NR_CONS, NR_RS_LINES, and NR_PTYS determine the number of terminals the * system can handle. diff --git a/kernel/utility.c b/kernel/utility.c index 5df0c4469..3faef77d8 100755 --- a/kernel/utility.c +++ b/kernel/utility.c @@ -139,7 +139,10 @@ int c; /* character to append */ kmess.km_size += 1; kmess.km_next = (kmess.km_next + 1) % KMESS_BUF_SIZE; } else { - send_sig(OUTPUT_PROC_NR, SIGKMESS); + int p, outprocs[] = OUTPUT_PROCS_ARRAY; + for(p = 0; outprocs[p] != NONE; p++) { + send_sig(outprocs[p], SIGKMESS); + } } } diff --git a/lib/sysutil/kputc.c b/lib/sysutil/kputc.c index 0a52c2dc8..ca0e4457c 100644 --- a/lib/sysutil/kputc.c +++ b/lib/sysutil/kputc.c @@ -21,13 +21,17 @@ int c; message m; if ((c == 0 && buf_count > 0) || buf_count == sizeof(print_buf)) { + int procs[] = OUTPUT_PROCS_ARRAY; + int p; - /* Send the buffer to the OUTPUT_PROC_NR driver. */ - m.DIAG_BUF_COUNT = buf_count; - m.DIAG_PRINT_BUF = print_buf; - m.DIAG_PROC_NR = SELF; - m.m_type = DIAGNOSTICS; - (void) _sendrec(OUTPUT_PROC_NR, &m); + for(p = 0; procs[p] != NONE; p++) { + /* Send the buffer to this output driver. */ + m.DIAG_BUF_COUNT = buf_count; + m.DIAG_PRINT_BUF = print_buf; + m.DIAG_PROC_NR = SELF; + m.m_type = DIAGNOSTICS; + (void) _sendrec(procs[p], &m); + } buf_count = 0; /* If the output fails, e.g., due to an ELOCKED, do not retry output