minix/servers/is/dmp_fs.c

108 lines
3.2 KiB
C
Raw Normal View History

2005-04-21 16:53:53 +02:00
/* This file contains procedures to dump to FS' data structures.
*
* The entry points into this file are
* dtab_dump: display device <-> driver mappings
2005-04-21 16:53:53 +02:00
* fproc_dump: display FS process table
*
* Created:
* Oct 01, 2004: by Jorrit N. Herder
*/
2005-10-20 22:28:54 +02:00
#include "inc.h"
#include "../mfs/const.h"
2012-02-13 16:28:04 +01:00
#include "../vfs/const.h"
#include "../vfs/fproc.h"
#include "../vfs/dmap.h"
#include <minix/dmap.h>
2005-04-21 16:53:53 +02:00
2012-03-25 20:25:53 +02:00
struct fproc fproc[NR_PROCS];
struct dmap dmap[NR_DEVICES];
2005-04-21 16:53:53 +02:00
/*===========================================================================*
* fproc_dmp *
*===========================================================================*/
2012-03-25 20:25:53 +02:00
void fproc_dmp()
2005-04-21 16:53:53 +02:00
{
struct fproc *fp;
int i, j, nfds, n=0;
2005-04-21 16:53:53 +02:00
static int prev_i;
if (getsysinfo(VFS_PROC_NR, SI_PROC_TAB, fproc, sizeof(fproc)) != OK) {
printf("Error obtaining table from VFS. Perhaps recompile IS?\n");
return;
}
printf("File System (FS) process table dump\n");
printf("-nr- -pid- -tty- -umask- --uid-- --gid-- -ldr-fds-sus-rev-proc-\n");
2005-04-21 16:53:53 +02:00
for (i=prev_i; i<NR_PROCS; i++) {
fp = &fproc[i];
if (fp->fp_pid <= 0) continue;
if (++n > 22) break;
for (j = nfds = 0; j < OPEN_MAX; j++)
if (fp->fp_filp[j] != NULL) nfds++;
printf("%3d %4d %2d/%d 0x%05x %2d (%2d) %2d (%2d) %3d %3d %3d %3d ",
2011-08-17 15:23:45 +02:00
i, fp->fp_pid,
major(fp->fp_tty), minor(fp->fp_tty),
fp->fp_umask,
fp->fp_realuid, fp->fp_effuid, fp->fp_realgid, fp->fp_effgid,
!!(fp->fp_flags & FP_SESLDR), nfds,
2011-08-17 15:23:45 +02:00
fp->fp_blocked_on, !!(fp->fp_flags & FP_REVIVED)
);
if (fp->fp_blocked_on == FP_BLOCKED_ON_OTHER)
printf("%4d\n", fp->fp_task);
else
printf(" nil\n");
2005-04-21 16:53:53 +02:00
}
if (i >= NR_PROCS) i = 0;
else printf("--more--\r");
prev_i = i;
}
/*===========================================================================*
* dmap_flags *
*===========================================================================*/
2012-03-25 20:25:53 +02:00
static char * dmap_flags(int flags)
{
static char fl[10];
2012-08-07 13:09:09 +02:00
strlcpy(fl, "-----", sizeof(fl));
if(flags & DRV_FORCED) fl[0] = 'F';
return fl;
}
/*===========================================================================*
* dmap_style *
*===========================================================================*/
2012-03-25 20:25:53 +02:00
static char * dmap_style(int dev_style)
{
switch(dev_style) {
2012-08-07 13:09:09 +02:00
case STYLE_DEV: return "STYLE_DEV";
case STYLE_TTY: return "STYLE_TTY";
case STYLE_CTTY: return "STYLE_CTTY";
default: return "UNKNOWN";
}
}
2005-04-21 16:53:53 +02:00
/*===========================================================================*
* dtab_dmp *
*===========================================================================*/
2012-03-25 20:25:53 +02:00
void dtab_dmp()
2005-04-21 16:53:53 +02:00
{
int i;
if (getsysinfo(VFS_PROC_NR, SI_DMAP_TAB, dmap, sizeof(dmap)) != OK) {
printf("Error obtaining table from VFS. Perhaps recompile IS?\n");
return;
}
printf("File System (FS) device <-> driver mappings\n");
printf(" Label Major Driver ept Flags Style \n");
printf("------------- ----- ---------- ----- -------------\n");
for (i=0; i<NR_DEVICES; i++) {
if (dmap[i].dmap_driver == NONE) continue;
printf("%13s %5d %10d %s %-13s\n",
dmap[i].dmap_label, i, dmap[i].dmap_driver,
dmap_flags(dmap[i].dmap_flags), dmap_style(dmap[i].dmap_style));
2005-04-21 16:53:53 +02:00
}
}