1433d6423SLionel Sambuc /* This file contains procedures to dump RS data structures.
2433d6423SLionel Sambuc *
3433d6423SLionel Sambuc * The entry points into this file are
4433d6423SLionel Sambuc * rproc_dump: display RS system process table
5433d6423SLionel Sambuc *
6433d6423SLionel Sambuc * Created:
7433d6423SLionel Sambuc * Oct 03, 2005: by Jorrit N. Herder
8433d6423SLionel Sambuc */
9433d6423SLionel Sambuc
10433d6423SLionel Sambuc #include "inc.h"
11433d6423SLionel Sambuc #include <minix/timers.h>
12433d6423SLionel Sambuc #include <minix/rs.h>
13433d6423SLionel Sambuc #include "kernel/priv.h"
14433d6423SLionel Sambuc #include "../rs/const.h"
15433d6423SLionel Sambuc #include "../rs/type.h"
16433d6423SLionel Sambuc
17433d6423SLionel Sambuc struct rprocpub rprocpub[NR_SYS_PROCS];
18433d6423SLionel Sambuc struct rproc rproc[NR_SYS_PROCS];
19433d6423SLionel Sambuc
20433d6423SLionel Sambuc static char *s_flags_str(int flags, int sys_flags);
21433d6423SLionel Sambuc
22433d6423SLionel Sambuc /*===========================================================================*
23433d6423SLionel Sambuc * rproc_dmp *
24433d6423SLionel Sambuc *===========================================================================*/
25*4aa48abaSRichard Sailer void
rproc_dmp(void)26*4aa48abaSRichard Sailer rproc_dmp(void)
27433d6423SLionel Sambuc {
28433d6423SLionel Sambuc struct rproc *rp;
29433d6423SLionel Sambuc struct rprocpub *rpub;
30433d6423SLionel Sambuc int i, n=0;
31433d6423SLionel Sambuc static int prev_i=0;
32433d6423SLionel Sambuc
33433d6423SLionel Sambuc if (getsysinfo(RS_PROC_NR, SI_PROCPUB_TAB, rprocpub, sizeof(rprocpub)) != OK
34433d6423SLionel Sambuc || getsysinfo(RS_PROC_NR, SI_PROC_TAB, rproc, sizeof(rproc)) != OK) {
35433d6423SLionel Sambuc printf("Error obtaining table from RS. Perhaps recompile IS?\n");
36433d6423SLionel Sambuc return;
37433d6423SLionel Sambuc }
38433d6423SLionel Sambuc
39433d6423SLionel Sambuc printf("Reincarnation Server (RS) system process table dump\n");
40433d6423SLionel Sambuc printf("----label---- endpoint- -pid- flags- -dev- -T- alive_tm starts command\n");
41433d6423SLionel Sambuc for (i=prev_i; i<NR_SYS_PROCS; i++) {
42433d6423SLionel Sambuc rp = &rproc[i];
43433d6423SLionel Sambuc rpub = &rprocpub[i];
44433d6423SLionel Sambuc if (! (rp->r_flags & RS_IN_USE)) continue;
45433d6423SLionel Sambuc if (++n > 22) break;
465ae1a533SBen Gras printf("%13s %9d %5d %6s %4d %4lu %8u %5dx %s",
47433d6423SLionel Sambuc rpub->label, rpub->endpoint, rp->r_pid,
48433d6423SLionel Sambuc s_flags_str(rp->r_flags, rpub->sys_flags), rpub->dev_nr,
495ae1a533SBen Gras (unsigned long) rp->r_period,
505ae1a533SBen Gras (unsigned int) rp->r_alive_tm, rp->r_restarts,
51433d6423SLionel Sambuc rp->r_args
52433d6423SLionel Sambuc );
53433d6423SLionel Sambuc printf("\n");
54433d6423SLionel Sambuc }
55433d6423SLionel Sambuc if (i >= NR_SYS_PROCS) i = 0;
56433d6423SLionel Sambuc else printf("--more--\r");
57433d6423SLionel Sambuc prev_i = i;
58433d6423SLionel Sambuc }
59433d6423SLionel Sambuc
60433d6423SLionel Sambuc
s_flags_str(int flags,int sys_flags)61433d6423SLionel Sambuc static char *s_flags_str(int flags, int sys_flags)
62433d6423SLionel Sambuc {
63433d6423SLionel Sambuc static char str[10];
64433d6423SLionel Sambuc str[0] = (flags & RS_ACTIVE) ? 'A' : '-';
65433d6423SLionel Sambuc str[1] = (flags & RS_UPDATING) ? 'U' : '-';
66433d6423SLionel Sambuc str[2] = (flags & RS_EXITING) ? 'E' : '-';
67433d6423SLionel Sambuc str[3] = (flags & RS_NOPINGREPLY) ? 'N' : '-';
68433d6423SLionel Sambuc str[4] = (sys_flags & SF_USE_COPY) ? 'C' : '-';
69433d6423SLionel Sambuc str[5] = (sys_flags & SF_USE_REPL) ? 'R' : '-';
70433d6423SLionel Sambuc str[6] = '\0';
71433d6423SLionel Sambuc
72433d6423SLionel Sambuc return(str);
73433d6423SLionel Sambuc }
74433d6423SLionel Sambuc
75