make getsysinfo() a system-land call

This commit is contained in:
David van Moolenbroek
2010-09-14 21:50:05 +00:00
parent d299a6422b
commit 354da24f5b
24 changed files with 89 additions and 240 deletions

View File

@@ -21,6 +21,7 @@
#include <minix/com.h>
#include <minix/ds.h>
#include <minix/syslib.h>
#include <minix/sysinfo.h>
#include <minix/sysutil.h>
#include <minix/keymap.h>
#include <minix/bitmap.h>
@@ -29,7 +30,6 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <signal.h>
#include "proto.h"

View File

@@ -72,7 +72,7 @@ PUBLIC int main(int argc, char **argv)
case DS_SNAPSHOT:
result = do_snapshot(&m);
break;
case GETSYSINFO:
case COMMON_GETSYSINFO:
result = do_getsysinfo(&m);
break;
default:

View File

@@ -18,6 +18,7 @@
#include <minix/const.h>
#include <minix/com.h>
#include <minix/syslib.h>
#include <minix/sysinfo.h>
#include <minix/sysutil.h>
#include <minix/keymap.h>
#include <minix/bitmap.h>
@@ -25,7 +26,6 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <signal.h>
#include <machine/archtypes.h>

View File

@@ -128,6 +128,9 @@ PUBLIC int main()
else
result= ENOSYS;
break;
case COMMON_GETSYSINFO:
result = do_getsysinfo();
break;
default:
/* Else, if the system call number is valid, perform the
* call.

View File

@@ -60,8 +60,6 @@ PRIVATE char *uts_tbl[] = {
PUBLIC unsigned long calls_stats[NCALLS];
#endif
FORWARD _PROTOTYPE( int getpciinfo, (struct pciinfo *pciinfo) );
/*===========================================================================*
* do_procstat *
*===========================================================================*/
@@ -160,7 +158,6 @@ PUBLIC int do_getsysinfo()
vir_bytes src_addr, dst_addr;
struct kinfo kinfo;
struct loadinfo loadinfo;
struct pciinfo pciinfo;
static struct proc proctab[NR_PROCS+NR_TASKS];
size_t len;
int s, r;
@@ -174,38 +171,25 @@ PUBLIC int do_getsysinfo()
return EPERM;
}
/* This call should no longer be used by user applications. In the future,
* requests from non-system processes should be denied. For now, just warn.
*/
if (call_nr == GETSYSINFO)
{
printf("PM: obsolete call of do_getsysinfo() by proc %d '%s'\n",
mp->mp_endpoint, mp->mp_name);
}
switch(m_in.info_what) {
case SI_KINFO: /* kernel info is obtained via PM */
sys_getkinfo(&kinfo);
src_addr = (vir_bytes) &kinfo;
len = sizeof(struct kinfo);
break;
case SI_PROC_ADDR: /* get address of PM process table */
proc_addr = &mproc[0];
src_addr = (vir_bytes) &proc_addr;
len = sizeof(struct mproc *);
break;
case SI_PROC_TAB: /* copy entire process table */
src_addr = (vir_bytes) mproc;
len = sizeof(struct mproc) * NR_PROCS;
break;
case SI_KPROC_TAB: /* copy entire process table */
if((r=sys_getproctab(proctab)) != OK)
return r;
src_addr = (vir_bytes) proctab;
len = sizeof(proctab);
break;
case SI_LOADINFO: /* loadinfo is obtained via PM */
sys_getloadinfo(&loadinfo);
src_addr = (vir_bytes) &loadinfo;
len = sizeof(struct loadinfo);
break;
case SI_PCI_INFO: /* PCI info is obtained via PM */
if ((r=getpciinfo(&pciinfo)) != OK)
return r;
src_addr = (vir_bytes) &pciinfo;
len = sizeof(struct pciinfo);
break;
#if ENABLE_SYSCALL_STATS
case SI_CALL_STATS:
src_addr = (vir_bytes) calls_stats;
@@ -230,9 +214,11 @@ PUBLIC int do_getsysinfo_up()
vir_bytes src_addr, dst_addr;
struct loadinfo loadinfo;
size_t len, real_len;
u64_t idle_tsc;
int s;
printf("PM: obsolete call of do_getsysinfo_up() by proc %d '%s'\n",
mp->mp_endpoint, mp->mp_name);
switch(m_in.SIU_WHAT) {
case SIU_LOADINFO: /* loadinfo is obtained via PM */
if ((s = sys_getloadinfo(&loadinfo)) != OK)
@@ -244,12 +230,6 @@ PUBLIC int do_getsysinfo_up()
src_addr = (vir_bytes) &system_hz;
real_len = sizeof(system_hz);
break;
case SIU_IDLETSC:
if ((s = sys_getidletsc(&idle_tsc)) != OK)
return s;
src_addr = (vir_bytes) &idle_tsc;
real_len = sizeof(idle_tsc);
break;
default:
return(EINVAL);
}
@@ -580,45 +560,3 @@ char *brk_addr;
_brksize = brk_addr;
return 0;
}
/*===========================================================================*
* getpciinfo *
*===========================================================================*/
PRIVATE int getpciinfo(pciinfo)
struct pciinfo *pciinfo;
{
int devind, r;
struct pciinfo_entry *entry;
char *name;
u16_t vid, did;
/* look up PCI process number */
pci_init();
/* start enumerating devices */
entry = pciinfo->pi_entries;
r = pci_first_dev(&devind, &vid, &did);
while (r)
{
/* fetch device name */
name = pci_dev_name(vid, did);
if (!name)
name = "";
/* store device information in table */
assert((char *) entry < (char *) (pciinfo + 1));
entry->pie_vid = vid;
entry->pie_did = did;
strncpy(entry->pie_name, name, sizeof(entry->pie_name));
entry->pie_name[sizeof(entry->pie_name) - 1] = 0;
entry++;
/* continue with the next device */
r = pci_next_dev(&devind, &vid, &did);
}
/* store number of entries */
pciinfo->pi_count = entry - pciinfo->pi_entries;
return OK;
}

View File

@@ -26,6 +26,7 @@
#include <minix/const.h>
#include <minix/com.h>
#include <minix/syslib.h>
#include <minix/sysinfo.h>
#include <minix/sysutil.h>
#include <minix/keymap.h>
#include <minix/bitmap.h>
@@ -46,7 +47,6 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <signal.h>
#include <assert.h>
#include <sys/param.h>

View File

@@ -91,7 +91,7 @@ PUBLIC int main(void)
* Handle the request and send a reply to the caller.
*/
else {
if (call_nr != GETSYSINFO &&
if (call_nr != COMMON_GETSYSINFO &&
(call_nr < RS_RQ_BASE || call_nr >= RS_RQ_BASE+0x100))
{
/* Ignore invalid requests. Do not try to reply. */
@@ -111,7 +111,8 @@ PUBLIC int main(void)
case RS_UPDATE: result = do_update(&m); break;
case RS_CLONE: result = do_clone(&m); break;
case RS_EDIT: result = do_edit(&m); break;
case GETSYSINFO: result = do_getsysinfo(&m); break;
case COMMON_GETSYSINFO:
result = do_getsysinfo(&m); break;
case RS_LOOKUP: result = do_lookup(&m); break;
/* Ready messages. */
case RS_INIT: result = do_init_ready(&m); break;

View File

@@ -130,18 +130,14 @@ message *m; /* request/reply message pointer */
/* Initialize global variables for the nested call */
set_globals(m);
/* Perform the nested call */
if (call_nr < 0 || call_nr >= NCALLS) {
/* Perform the nested call - only getsysinfo() is allowed right now */
if (call_nr == COMMON_GETSYSINFO) {
r = do_getsysinfo();
} else {
printf("VFS: invalid nested call %d from FS %d\n", call_nr,
who_e);
r = ENOSYS;
} else {
#if ENABLE_SYSCALL_STATS
calls_stats[call_nr]++;
#endif
r = (*call_vec[call_nr])();
}
/* Store the result, and restore original global variables */

View File

@@ -162,7 +162,10 @@ PUBLIC int main(void)
error= do_mapdriver();
if (error != SUSPEND) reply(who_e, error);
break;
case COMMON_GETSYSINFO:
error= do_getsysinfo();
if (error != SUSPEND) reply(who_e, error);
break;
default:
/* Call the internal function that does the work. */
if (call_nr < 0 || call_nr >= NCALLS) {

View File

@@ -26,6 +26,7 @@
#include <minix/safecopies.h>
#include <minix/endpoint.h>
#include <minix/com.h>
#include <minix/sysinfo.h>
#include <minix/u64.h>
#include <sys/ptrace.h>
#include <sys/svrctl.h>
@@ -72,12 +73,15 @@ PUBLIC int do_getsysinfo()
if (!super_user) return(EPERM);
/* This call should no longer be used by user applications. In the future,
* requests from non-system processes should be denied. For now, just warn.
*/
if (call_nr == GETSYSINFO) {
printf("VFS: obsolete call of do_getsysinfo() by proc %d\n",
fp->fp_endpoint);
}
switch(m_in.info_what) {
case SI_PROC_ADDR:
proc_addr = &fproc[0];
src_addr = (vir_bytes) &proc_addr;
len = sizeof(struct fproc *);
break;
case SI_PROC_TAB:
src_addr = (vir_bytes) fproc;
len = sizeof(struct fproc) * NR_PROCS;

View File

@@ -112,7 +112,7 @@ PUBLIC _PROTOTYPE (int (*call_vec[]), (void) ) = {
do_ftruncate, /* 94 = truncate */
do_chmod, /* 95 = fchmod */
do_chown, /* 96 = fchown */
no_sys, /* 97 = getsysinfo_up */
no_sys, /* 97 = (getsysinfo_up) */
no_sys, /* 98 = (sprofile) */
no_sys, /* 99 = (cprofile) */
/* THE MINIX3 ABI ENDS HERE */