1 /* This file contains procedures to dump RS data structures. 2 * 3 * The entry points into this file are 4 * rproc_dump: display RS system process table 5 * 6 * Created: 7 * Oct 03, 2005: by Jorrit N. Herder 8 */ 9 10 #include "inc.h" 11 #include <minix/timers.h> 12 #include <minix/rs.h> 13 #include "kernel/priv.h" 14 #include "../rs/const.h" 15 #include "../rs/type.h" 16 17 struct rprocpub rprocpub[NR_SYS_PROCS]; 18 struct rproc rproc[NR_SYS_PROCS]; 19 20 static char *s_flags_str(int flags, int sys_flags); 21 22 /*===========================================================================* 23 * rproc_dmp * 24 *===========================================================================*/ 25 void 26 rproc_dmp(void) 27 { 28 struct rproc *rp; 29 struct rprocpub *rpub; 30 int i, n=0; 31 static int prev_i=0; 32 33 if (getsysinfo(RS_PROC_NR, SI_PROCPUB_TAB, rprocpub, sizeof(rprocpub)) != OK 34 || getsysinfo(RS_PROC_NR, SI_PROC_TAB, rproc, sizeof(rproc)) != OK) { 35 printf("Error obtaining table from RS. Perhaps recompile IS?\n"); 36 return; 37 } 38 39 printf("Reincarnation Server (RS) system process table dump\n"); 40 printf("----label---- endpoint- -pid- flags- -dev- -T- alive_tm starts command\n"); 41 for (i=prev_i; i<NR_SYS_PROCS; i++) { 42 rp = &rproc[i]; 43 rpub = &rprocpub[i]; 44 if (! (rp->r_flags & RS_IN_USE)) continue; 45 if (++n > 22) break; 46 printf("%13s %9d %5d %6s %4d %4lu %8u %5dx %s", 47 rpub->label, rpub->endpoint, rp->r_pid, 48 s_flags_str(rp->r_flags, rpub->sys_flags), rpub->dev_nr, 49 (unsigned long) rp->r_period, 50 (unsigned int) rp->r_alive_tm, rp->r_restarts, 51 rp->r_args 52 ); 53 printf("\n"); 54 } 55 if (i >= NR_SYS_PROCS) i = 0; 56 else printf("--more--\r"); 57 prev_i = i; 58 } 59 60 61 static char *s_flags_str(int flags, int sys_flags) 62 { 63 static char str[10]; 64 str[0] = (flags & RS_ACTIVE) ? 'A' : '-'; 65 str[1] = (flags & RS_UPDATING) ? 'U' : '-'; 66 str[2] = (flags & RS_EXITING) ? 'E' : '-'; 67 str[3] = (flags & RS_NOPINGREPLY) ? 'N' : '-'; 68 str[4] = (sys_flags & SF_USE_COPY) ? 'C' : '-'; 69 str[5] = (sys_flags & SF_USE_REPL) ? 'R' : '-'; 70 str[6] = '\0'; 71 72 return(str); 73 } 74 75