xref: /minix3/minix/servers/is/dmp_ds.c (revision 4aa48abab95b2c3bef55ef84ec4b7c49368fb6f8)
1433d6423SLionel Sambuc #include "inc.h"
2433d6423SLionel Sambuc #include "../ds/store.h"
3433d6423SLionel Sambuc 
4433d6423SLionel Sambuc #define LINES 22
5433d6423SLionel Sambuc 
650b7f13fSCristiano Giuffrida static struct data_store noxfer_ds_store[NR_DS_KEYS];
7433d6423SLionel Sambuc 
8*4aa48abaSRichard Sailer void
data_store_dmp(void)9*4aa48abaSRichard Sailer data_store_dmp(void)
10433d6423SLionel Sambuc {
11433d6423SLionel Sambuc   struct data_store *p;
12433d6423SLionel Sambuc   static int prev_i = 0;
13433d6423SLionel Sambuc   int i, n = 0;
14433d6423SLionel Sambuc 
1550b7f13fSCristiano Giuffrida   if (getsysinfo(DS_PROC_NR, SI_DATA_STORE, noxfer_ds_store, sizeof(noxfer_ds_store)) != OK) {
16433d6423SLionel Sambuc 	printf("Error obtaining table from DS. Perhaps recompile IS?\n");
17433d6423SLionel Sambuc 	return;
18433d6423SLionel Sambuc   }
19433d6423SLionel Sambuc 
20433d6423SLionel Sambuc   printf("Data store contents:\n");
21433d6423SLionel Sambuc   printf("-slot- -----------key----------- -----owner----- ---type--- ----value---\n");
22433d6423SLionel Sambuc   for(i = prev_i; i < NR_DS_KEYS && n < LINES; i++) {
2350b7f13fSCristiano Giuffrida 	p = &noxfer_ds_store[i];
24433d6423SLionel Sambuc 	if(!(p->flags & DSF_IN_USE))
25433d6423SLionel Sambuc 		continue;
26433d6423SLionel Sambuc 
27433d6423SLionel Sambuc 	printf("%6d %-25s %-15s ", i, p->key, p->owner);
28433d6423SLionel Sambuc 	switch(p->flags & DSF_MASK_TYPE) {
29433d6423SLionel Sambuc 	case DSF_TYPE_U32:
30433d6423SLionel Sambuc 		printf("%-10s %12u\n", "U32", p->u.u32);
31433d6423SLionel Sambuc 		break;
32433d6423SLionel Sambuc 	case DSF_TYPE_STR:
33433d6423SLionel Sambuc 		printf("%-10s %12s\n", "STR", (char*) p->u.mem.data);
34433d6423SLionel Sambuc 		break;
35433d6423SLionel Sambuc 	case DSF_TYPE_MEM:
363c8950ccSBen Gras 		printf("%-10s %12zu\n", "MEM", p->u.mem.length);
37433d6423SLionel Sambuc 		break;
38433d6423SLionel Sambuc 	case DSF_TYPE_LABEL:
39433d6423SLionel Sambuc 		printf("%-10s %12u\n", "LABEL", p->u.u32);
40433d6423SLionel Sambuc 		break;
41433d6423SLionel Sambuc 	default:
42433d6423SLionel Sambuc 		return;
43433d6423SLionel Sambuc 	}
44433d6423SLionel Sambuc 
45433d6423SLionel Sambuc 	n++;
46433d6423SLionel Sambuc   }
47433d6423SLionel Sambuc 
48433d6423SLionel Sambuc   if (i >= NR_DS_KEYS) i = 0;
49433d6423SLionel Sambuc   else printf("--more--\r");
50433d6423SLionel Sambuc   prev_i = i;
51433d6423SLionel Sambuc }
52433d6423SLionel Sambuc 
53