xref: /minix3/minix/servers/is/dmp_fs.c (revision e3b8d4bb58a799dc7fd563ac39bf3015762af03b)
1433d6423SLionel Sambuc /* This file contains procedures to dump to FS' data structures.
2433d6423SLionel Sambuc  *
3433d6423SLionel Sambuc  * The entry points into this file are
4433d6423SLionel Sambuc  *   dtab_dump:   	display device <-> driver mappings
5433d6423SLionel Sambuc  *   fproc_dump:   	display FS process table
6433d6423SLionel Sambuc  *
7433d6423SLionel Sambuc  * Created:
8433d6423SLionel Sambuc  *   Oct 01, 2004:	by Jorrit N. Herder
9433d6423SLionel Sambuc  */
10433d6423SLionel Sambuc 
11433d6423SLionel Sambuc #include "inc.h"
12433d6423SLionel Sambuc #include "mfs/const.h"
13433d6423SLionel Sambuc #include "vfs/const.h"
14433d6423SLionel Sambuc #include "vfs/fproc.h"
15433d6423SLionel Sambuc #include "vfs/dmap.h"
16433d6423SLionel Sambuc #include <minix/dmap.h>
17433d6423SLionel Sambuc 
18433d6423SLionel Sambuc struct fproc fproc[NR_PROCS];
19433d6423SLionel Sambuc struct dmap dmap[NR_DEVICES];
20433d6423SLionel Sambuc 
21433d6423SLionel Sambuc /*===========================================================================*
22433d6423SLionel Sambuc  *				fproc_dmp				     *
23433d6423SLionel Sambuc  *===========================================================================*/
244aa48abaSRichard Sailer void
fproc_dmp(void)254aa48abaSRichard Sailer fproc_dmp(void)
26433d6423SLionel Sambuc {
27433d6423SLionel Sambuc   struct fproc *fp;
28433d6423SLionel Sambuc   int i, j, nfds, n=0;
29433d6423SLionel Sambuc   static int prev_i;
30433d6423SLionel Sambuc 
31433d6423SLionel Sambuc   if (getsysinfo(VFS_PROC_NR, SI_PROC_TAB, fproc, sizeof(fproc)) != OK) {
32433d6423SLionel Sambuc 	printf("Error obtaining table from VFS. Perhaps recompile IS?\n");
33433d6423SLionel Sambuc 	return;
34433d6423SLionel Sambuc   }
35433d6423SLionel Sambuc 
36433d6423SLionel Sambuc   printf("File System (FS) process table dump\n");
37433d6423SLionel Sambuc   printf("-nr- -pid- -tty- -umask- --uid-- --gid-- -ldr-fds-sus-rev-proc-\n");
38433d6423SLionel Sambuc   for (i=prev_i; i<NR_PROCS; i++) {
39433d6423SLionel Sambuc   	fp = &fproc[i];
40433d6423SLionel Sambuc   	if (fp->fp_pid <= 0) continue;
41433d6423SLionel Sambuc   	if (++n > 22) break;
42433d6423SLionel Sambuc 	for (j = nfds = 0; j < OPEN_MAX; j++)
43433d6423SLionel Sambuc 		if (fp->fp_filp[j] != NULL) nfds++;
44433d6423SLionel Sambuc 	printf("%3d  %4d  %2d/%d  0x%05x %2d (%2d) %2d (%2d) %3d %3d %3d %3d ",
45433d6423SLionel Sambuc 		i, fp->fp_pid,
46433d6423SLionel Sambuc 		major(fp->fp_tty), minor(fp->fp_tty),
47433d6423SLionel Sambuc 		fp->fp_umask,
48433d6423SLionel Sambuc 		fp->fp_realuid, fp->fp_effuid, fp->fp_realgid, fp->fp_effgid,
49433d6423SLionel Sambuc 		!!(fp->fp_flags & FP_SESLDR), nfds,
50433d6423SLionel Sambuc 		fp->fp_blocked_on, !!(fp->fp_flags & FP_REVIVED)
51433d6423SLionel Sambuc 	);
52232819ddSDavid van Moolenbroek 	if (fp->fp_blocked_on == FP_BLOCKED_ON_CDEV)
53232819ddSDavid van Moolenbroek 		printf("%4d\n", fp->fp_cdev.endpt);
54*e3b8d4bbSDavid van Moolenbroek 	/* TODO: for FP_BLOCKED_ON_SDEV we do not have the endpoint.. */
55433d6423SLionel Sambuc 	else
56433d6423SLionel Sambuc 		printf(" nil\n");
57433d6423SLionel Sambuc   }
58433d6423SLionel Sambuc   if (i >= NR_PROCS) i = 0;
59433d6423SLionel Sambuc   else printf("--more--\r");
60433d6423SLionel Sambuc   prev_i = i;
61433d6423SLionel Sambuc }
62433d6423SLionel Sambuc 
63433d6423SLionel Sambuc /*===========================================================================*
64433d6423SLionel Sambuc  *				dtab_dmp				     *
65433d6423SLionel Sambuc  *===========================================================================*/
664aa48abaSRichard Sailer void
dtab_dmp(void)674aa48abaSRichard Sailer dtab_dmp(void)
68433d6423SLionel Sambuc {
69433d6423SLionel Sambuc     int i;
70433d6423SLionel Sambuc 
71433d6423SLionel Sambuc     if (getsysinfo(VFS_PROC_NR, SI_DMAP_TAB, dmap, sizeof(dmap)) != OK) {
72433d6423SLionel Sambuc         printf("Error obtaining table from VFS. Perhaps recompile IS?\n");
73433d6423SLionel Sambuc         return;
74433d6423SLionel Sambuc     }
75433d6423SLionel Sambuc 
76433d6423SLionel Sambuc     printf("File System (FS) device <-> driver mappings\n");
77433d6423SLionel Sambuc     printf("    Label     Major Driver ept\n");
78433d6423SLionel Sambuc     printf("------------- ----- ----------\n");
79433d6423SLionel Sambuc     for (i=0; i<NR_DEVICES; i++) {
80433d6423SLionel Sambuc         if (dmap[i].dmap_driver == NONE) continue;
81433d6423SLionel Sambuc         printf("%13s %5d %10d\n", dmap[i].dmap_label, i, dmap[i].dmap_driver);
82433d6423SLionel Sambuc     }
83433d6423SLionel Sambuc }
84