xref: /minix/minix/servers/is/dmp_ds.c (revision ebfedea0)
1 #include "inc.h"
2 #include "../ds/store.h"
3 
4 #define LINES 22
5 
6 static struct data_store noxfer_ds_store[NR_DS_KEYS];
7 
8 void data_store_dmp()
9 {
10   struct data_store *p;
11   static int prev_i = 0;
12   int i, n = 0;
13 
14   if (getsysinfo(DS_PROC_NR, SI_DATA_STORE, noxfer_ds_store, sizeof(noxfer_ds_store)) != OK) {
15 	printf("Error obtaining table from DS. Perhaps recompile IS?\n");
16 	return;
17   }
18 
19   printf("Data store contents:\n");
20   printf("-slot- -----------key----------- -----owner----- ---type--- ----value---\n");
21   for(i = prev_i; i < NR_DS_KEYS && n < LINES; i++) {
22 	p = &noxfer_ds_store[i];
23 	if(!(p->flags & DSF_IN_USE))
24 		continue;
25 
26 	printf("%6d %-25s %-15s ", i, p->key, p->owner);
27 	switch(p->flags & DSF_MASK_TYPE) {
28 	case DSF_TYPE_U32:
29 		printf("%-10s %12u\n", "U32", p->u.u32);
30 		break;
31 	case DSF_TYPE_STR:
32 		printf("%-10s %12s\n", "STR", (char*) p->u.mem.data);
33 		break;
34 	case DSF_TYPE_MEM:
35 		printf("%-10s %12zu\n", "MEM", p->u.mem.length);
36 		break;
37 	case DSF_TYPE_LABEL:
38 		printf("%-10s %12u\n", "LABEL", p->u.u32);
39 		break;
40 	default:
41 		return;
42 	}
43 
44 	n++;
45   }
46 
47   if (i >= NR_DS_KEYS) i = 0;
48   else printf("--more--\r");
49   prev_i = i;
50 }
51 
52