library function to retrieve kernel proc table and sanity check it
This commit is contained in:
parent
67fa273d00
commit
8379b08845
@ -187,4 +187,7 @@
|
|||||||
#define VERBOSEBOOT_MAX 3
|
#define VERBOSEBOOT_MAX 3
|
||||||
#define VERBOSEBOOTVARNAME "verbose"
|
#define VERBOSEBOOTVARNAME "verbose"
|
||||||
|
|
||||||
|
/* magic value to put in struct proc entries for sanity checks. */
|
||||||
|
#define PMAGIC 0xC0FFEE1
|
||||||
|
|
||||||
#endif /* _MINIX_CONST_H */
|
#endif /* _MINIX_CONST_H */
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
#include <minix/type.h>
|
#include <minix/type.h>
|
||||||
|
|
||||||
_PROTOTYPE( int getsysinfo, (endpoint_t who, int what, void *where) );
|
_PROTOTYPE( int getsysinfo, (endpoint_t who, int what, void *where) );
|
||||||
|
_PROTOTYPE( int minix_getkproctab, (void *pr, int nprocs, int assert));
|
||||||
_PROTOTYPE( ssize_t getsysinfo_up, (endpoint_t who, int what, size_t size,
|
_PROTOTYPE( ssize_t getsysinfo_up, (endpoint_t who, int what, size_t size,
|
||||||
void *where));
|
void *where));
|
||||||
|
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
#ifndef PROC_H
|
#ifndef PROC_H
|
||||||
#define PROC_H
|
#define PROC_H
|
||||||
|
|
||||||
|
#include <minix/const.h>
|
||||||
|
|
||||||
#ifndef __ASSEMBLY__
|
#ifndef __ASSEMBLY__
|
||||||
|
|
||||||
/* Here is the declaration of the process table. It contains all process
|
/* Here is the declaration of the process table. It contains all process
|
||||||
@ -102,7 +104,6 @@ struct proc {
|
|||||||
} p_vmrequest;
|
} p_vmrequest;
|
||||||
|
|
||||||
int p_found; /* consistency checking variables */
|
int p_found; /* consistency checking variables */
|
||||||
#define PMAGIC 0xC0FFEE1
|
|
||||||
int p_magic; /* check validity of proc pointers */
|
int p_magic; /* check validity of proc pointers */
|
||||||
|
|
||||||
#if DEBUG_TRACE
|
#if DEBUG_TRACE
|
||||||
|
@ -1,9 +1,23 @@
|
|||||||
|
|
||||||
#include <lib.h>
|
#include <lib.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <timers.h>
|
||||||
#include <minix/endpoint.h>
|
#include <minix/endpoint.h>
|
||||||
#define getsysinfo _getsysinfo
|
#define getsysinfo _getsysinfo
|
||||||
#define getsysinfo_up _getsysinfo_up
|
#define getsysinfo_up _getsysinfo_up
|
||||||
#include <minix/sysinfo.h>
|
#include <minix/sysinfo.h>
|
||||||
|
#include <minix/const.h>
|
||||||
|
|
||||||
|
#include <minix/ipc.h>
|
||||||
|
#include <minix/com.h>
|
||||||
|
#include <minix/sysinfo.h>
|
||||||
|
#include <minix/config.h>
|
||||||
|
#include <minix/type.h>
|
||||||
|
#include <minix/const.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#include <machine/archtypes.h>
|
||||||
|
#include "../../../kernel/proc.h"
|
||||||
|
|
||||||
PUBLIC int getsysinfo(who, what, where)
|
PUBLIC int getsysinfo(who, what, where)
|
||||||
endpoint_t who; /* from whom to request info */
|
endpoint_t who; /* from whom to request info */
|
||||||
@ -17,6 +31,35 @@ void *where; /* where to put it */
|
|||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PUBLIC int minix_getkproctab(void *vpr, int nprocs, int assert)
|
||||||
|
{
|
||||||
|
int r, i, fail = 0;
|
||||||
|
struct proc *pr = vpr;
|
||||||
|
|
||||||
|
if((r=getsysinfo(PM_PROC_NR, SI_KPROC_TAB, pr)) < 0)
|
||||||
|
return r;
|
||||||
|
|
||||||
|
for(i = 0; i < nprocs; i++) {
|
||||||
|
if(pr[i].p_magic != PMAGIC) {
|
||||||
|
fail = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!fail)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if(assert) {
|
||||||
|
fprintf(stderr, "%s: process table failed sanity check.\n", getprogname());
|
||||||
|
fprintf(stderr, "is kernel out of sync?\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
errno = ENOSYS;
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
/* Unprivileged variant of getsysinfo. */
|
/* Unprivileged variant of getsysinfo. */
|
||||||
PUBLIC ssize_t getsysinfo_up(who, what, size, where)
|
PUBLIC ssize_t getsysinfo_up(who, what, size, where)
|
||||||
endpoint_t who; /* from whom to request info */
|
endpoint_t who; /* from whom to request info */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user