. new kernel call sysctl for generic unprivileged system operations;
now used for printing diagnostic messages through the kernel message buffer. this lets processes print diagnostics without sending messages to tty and log directly, simplifying the message protocol a lot and reducing difficulties with deadlocks and other situations in which diagnostics are blackholed (e.g. grants don't work). this makes DIAGNOSTICS(_S), ASYN_DIAGNOSTICS and DIAG_REPL obsolete, although tty and log still accept the codes for 'old' binaries. This also simplifies diagnostics in several servers and drivers - only tty needs its own kputc() now. . simplifications in vfs, and some effort to get the vnode references right (consistent) even during shutdown. m_mounted_on is now NULL for root filesystems (!) (the original and new root), a less awkward special case than 'm_mounted_on == m_root_node'. root now has exactly one reference, to root, if no files are open, just like all other filesystems. m_driver_e is unused.
This commit is contained in:
@@ -9,9 +9,7 @@
|
||||
|
||||
#include "sysutil.h"
|
||||
|
||||
static char print_buf[80*25]; /* output is buffered here */
|
||||
|
||||
int kputc_use_private_grants= 0;
|
||||
static char print_buf[DIAG_BUFSIZE]; /* output is buffered here */
|
||||
|
||||
/*===========================================================================*
|
||||
* kputc *
|
||||
@@ -24,62 +22,8 @@ int c;
|
||||
message m;
|
||||
|
||||
if ((c == 0 && buf_count > 0) || buf_count == sizeof(print_buf)) {
|
||||
#define PRINTPROCS (sizeof(procs)/sizeof(procs[0]))
|
||||
int procs[] = OUTPUT_PROCS_ARRAY;
|
||||
static int firstprint = 1;
|
||||
static cp_grant_id_t printgrants[PRINTPROCS];
|
||||
int p;
|
||||
|
||||
if (kputc_use_private_grants)
|
||||
{
|
||||
for (p= 0; p<PRINTPROCS; p++)
|
||||
printgrants[p]= GRANT_INVALID;
|
||||
firstprint= 0;
|
||||
}
|
||||
if(firstprint) {
|
||||
for(p = 0; procs[p] != NONE; p++) {
|
||||
printgrants[p] = GRANT_INVALID;
|
||||
}
|
||||
|
||||
firstprint = 0;
|
||||
|
||||
/* First time? Initialize grant table;
|
||||
* Grant printing processes read copy access to our
|
||||
* print buffer forever. (So buffer can't be on stack!)
|
||||
*/
|
||||
for(p = 0; procs[p] != NONE; p++) {
|
||||
printgrants[p] = cpf_grant_direct(procs[p],
|
||||
(vir_bytes) print_buf,
|
||||
sizeof(print_buf), CPF_READ);
|
||||
}
|
||||
}
|
||||
|
||||
for(p = 0; procs[p] != NONE; p++) {
|
||||
/* Send the buffer to this output driver. */
|
||||
int may_asyn = 0;
|
||||
m.DIAG_BUF_COUNT = buf_count;
|
||||
if(GRANT_VALID(printgrants[p])) {
|
||||
m.m_type = DIAGNOSTICS_S;
|
||||
m.DIAG_PRINT_BUF_G = (char *) printgrants[p];
|
||||
may_asyn = 1;
|
||||
} else {
|
||||
m.m_type = DIAGNOSTICS;
|
||||
m.DIAG_PRINT_BUF_G = print_buf;
|
||||
}
|
||||
if(may_asyn && procs[p] == LOG_PROC_NR) {
|
||||
m.m_type = ASYN_DIAGNOSTICS;
|
||||
(void) asynsend(procs[p], &m);
|
||||
} else {
|
||||
sendrec(procs[p], &m);
|
||||
}
|
||||
}
|
||||
|
||||
sys_sysctl(SYSCTL_CODE_DIAG, print_buf, buf_count);
|
||||
buf_count = 0;
|
||||
|
||||
/* If the output fails, e.g., due to an ELOCKED, do not retry output
|
||||
* at the FS as if this were a normal user-land printf(). This may
|
||||
* result in even worse problems.
|
||||
*/
|
||||
}
|
||||
if (c != 0) {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user