int main (int argc, char *argv[])
{
- int r, param;
+ int param;
endpoint_t proc_e = NONE;
struct sysgetenv sysgetenv;
- message m;
char *to_whom, *operation, *what, *value;
unsigned i;
else
usage();
- m.m2_i1 = param;
- m.m2_p1 = (char *) &sysgetenv;
- r = _syscall(proc_e, SVRCTL, &m);
- if (r != 0) {
+ if (svrctl(param, &sysgetenv) != 0) {
if (errno == ESRCH)
fprintf(stderr, "invalid parameter: %s\n", what);
else if (errno == EINVAL)
else
usage();
- m.m2_i1 = param;
- m.m2_p1 = (char *) &sysgetenv;
- r = _syscall(proc_e, SVRCTL, &m);
- if (r != 0) {
+ if (svrctl(param, &sysgetenv) != 0) {
if (errno == ESRCH)
fprintf(stderr, "invalid parameter: %s\n", what);
else
-#define NCALLS 125 /* number of system calls allowed */
+#define NCALLS 129 /* number of system calls allowed */
/* In case it isn't obvious enough: this list is sorted numerically. */
#define EXIT 1
#define SIGRETURN 75
#define REBOOT 76
-#define SVRCTL 77
+#define PM_SVRCTL 77 /* to PM */
#define SYSUNAME 78
#define LLSEEK 81 /* to VFS */
#define GETVFSSTAT 82 /* to VFS */
#define VFS_VMCALL 117
#define MAPDRIVER 122 /* to VFS, map a device */
-#define GETRUSAGE 123 /* to PM, VFS */
+#define PM_GETRUSAGE 123 /* to PM */
#define VFS_CHECKPERMS 124 /* to VFS */
+
+#define PM_GETSYSINFO 125 /* to PM */
+#define VFS_GETSYSINFO 126 /* to VFS */
+#define VFS_GETRUSAGE 127 /* to VFS */
+#define VFS_SVRCTL 128 /* to VFS */
#define RS_LOOKUP (RS_RQ_BASE + 8) /* lookup server name */
+#define RS_GETSYSINFO (RS_RQ_BASE + 9) /* get system information */
+
#define RS_INIT (RS_RQ_BASE + 20) /* service init message */
#define RS_LU_PREPARE (RS_RQ_BASE + 21) /* prepare to update message */
#define DS_DELETE (DS_RQ_BASE + 4) /* delete data */
#define DS_SNAPSHOT (DS_RQ_BASE + 5) /* take a snapshot */
#define DS_RETRIEVE_LABEL (DS_RQ_BASE + 6) /* retrieve label's name */
+#define DS_GETSYSINFO (DS_RQ_BASE + 7) /* get system information */
/* DS field names */
# define DS_KEY_GRANT m2_i1 /* key for the data */
# define GCOV_BUFF_P m1_p1
# define GCOV_BUFF_SZ m1_i1
-/* Common request to several system servers: retrieve system information. */
-#define COMMON_GETSYSINFO (COMMON_RQ_BASE+2)
-# define SI_WHAT m1_i1
-# define SI_WHERE m1_p1
-# define SI_SIZE m1_i2
+/* Field names for the getsysinfo(2) call. */
+#define SI_WHAT m1_i1
+#define SI_WHERE m1_p1
+#define SI_SIZE m1_i2
/* PM field names */
/* BRK */
}
memset(r_usage, 0, sizeof(struct rusage));
- if ((rc = _syscall(PM_PROC_NR, GETRUSAGE, &m)) < 0)
+ if ((rc = _syscall(PM_PROC_NR, PM_GETRUSAGE, &m)) < 0)
return rc;
m.RU_RUSAGE_ADDR = r_usage;
- if ((rc = _syscall(VFS_PROC_NR, GETRUSAGE, &m)) < 0)
+ if ((rc = _syscall(VFS_PROC_NR, VFS_GETRUSAGE, &m)) < 0)
return rc;
m.RU_RUSAGE_ADDR = r_usage;
return _syscall(VM_PROC_NR, VM_GETRUSAGE, &m);
case 'M':
case 'S':
/* PM handles calls for itself and the kernel. */
- return _syscall(PM_PROC_NR, SVRCTL, &m);
+ return _syscall(PM_PROC_NR, PM_SVRCTL, &m);
case 'F':
case 'I':
/* VFS handles calls for itself and inet. */
- return _syscall(VFS_PROC_NR, SVRCTL, &m);
+ return _syscall(VFS_PROC_NR, VFS_SVRCTL, &m);
default:
errno = EINVAL;
return -1;
#include "syslib.h"
+
#include <string.h>
#include <minix/sysinfo.h>
#include <minix/com.h>
)
{
message m;
+ int call_nr;
+
+ switch (who) {
+ case PM_PROC_NR: call_nr = PM_GETSYSINFO; break;
+ case VFS_PROC_NR: call_nr = VFS_GETSYSINFO; break;
+ case RS_PROC_NR: call_nr = RS_GETSYSINFO; break;
+ case DS_PROC_NR: call_nr = DS_GETSYSINFO; break;
+ default:
+ return ENOSYS;
+ }
+
memset(&m, 0, sizeof(m));
m.SI_WHAT = what;
m.SI_WHERE = where;
m.SI_SIZE = size;
- return _taskcall(who, COMMON_GETSYSINFO, &m);
+ return _taskcall(who, call_nr, &m);
}
case DS_CHECK:
result = do_check(&m);
break;
- case COMMON_GETSYSINFO:
+ case DS_GETSYSINFO:
result = do_getsysinfo(&m);
break;
default:
else
result= ENOSYS;
break;
- case COMMON_GETSYSINFO:
- result = do_getsysinfo();
- break;
default:
/* Else, if the system call number is valid, perform the
* call.
do_sigprocmask, /* 74 = sigprocmask */
do_sigreturn, /* 75 = sigreturn */
do_reboot, /* 76 = reboot */
- do_svrctl, /* 77 = svrctl */
+ do_svrctl, /* 77 = pm_svrctl */
do_sysuname, /* 78 = sysuname */
no_sys, /* 79 = unused */
no_sys, /* 80 = (getdents) */
no_sys, /* 120 = unsused */
no_sys, /* 121 = (task reply) */
no_sys, /* 122 = (map driver ) */
- do_getrusage, /* 123 = getrusage */
+ do_getrusage, /* 123 = pm_getrusage */
no_sys, /* 124 = (checkperms) */
+ do_getsysinfo, /* 125 = pm_getsysinfo */
+ no_sys, /* 126 = (vfs_getsysinfo) */
+ no_sys, /* 127 = (vfs_getrusage) */
+ no_sys, /* 128 = (vfs_svrctl) */
};
/* This should not fail with "array size is negative": */
extern int dummy[sizeof(call_vec) == NCALLS * sizeof(call_vec[0]) ? 1 : -1];
* Handle the request and send a reply to the caller.
*/
else {
- if (call_nr != COMMON_GETSYSINFO &&
- (call_nr < RS_RQ_BASE || call_nr >= RS_RQ_BASE+0x100))
- {
- /* Ignore invalid requests. Do not try to reply. */
- printf("RS: warning: got invalid request %d from endpoint %d\n",
- call_nr, m.m_source);
- continue;
- }
-
/* Handler functions are responsible for permission checking. */
switch(call_nr) {
/* User requests. */
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 COMMON_GETSYSINFO:
- result = do_getsysinfo(&m); break;
+ case RS_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;
default:
printf("RS: warning: got unexpected request %d from %d\n",
m.m_type, m.m_source);
- result = EINVAL;
+ result = ENOSYS;
}
/* Finally send reply message, unless disabled. */
memset(&m_out, 0, sizeof(m_out));
- if (job_call_nr == COMMON_GETSYSINFO) {
- error = do_getsysinfo();
+ /* At this point we assume that we're dealing with a call that has been
+ * made specifically to VFS. Typically it will be a POSIX call from a
+ * normal process, but we also handle a few calls made by drivers such
+ * such as UDS and VND through here. Call the internal function that
+ * does the work.
+ */
+ if (job_call_nr < 0 || job_call_nr >= NCALLS) {
+ error = ENOSYS;
+ } else if (fp->fp_pid == PID_FREE) {
+ /* Process vanished before we were able to handle request.
+ * Replying has no use. Just drop it. */
+ error = SUSPEND;
} else {
- /* At this point we assume that we're dealing with a call that has been
- * made specifically to VFS. Typically it will be a POSIX call from a
- * normal process, but we also handle a few calls made by drivers such
- * such as UDS and VND through here. Call the internal function that
- * does the work.
- */
- if (job_call_nr < 0 || job_call_nr >= NCALLS) {
- error = ENOSYS;
- } else if (fp->fp_pid == PID_FREE) {
- /* Process vanished before we were able to handle request.
- * Replying has no use. Just drop it. */
- error = SUSPEND;
- } else {
#if ENABLE_SYSCALL_STATS
- calls_stats[job_call_nr]++;
+ calls_stats[job_call_nr]++;
#endif
- error = (*call_vec[job_call_nr])(&m_out);
- }
+ error = (*call_vec[job_call_nr])(&m_out);
}
/* Copy the results back to the user and send reply. */
/*===========================================================================*
* do_getsysinfo *
*===========================================================================*/
-int do_getsysinfo()
+int do_getsysinfo(message *UNUSED(m_out))
{
vir_bytes src_addr, dst_addr;
size_t len, buf_size;
int do_fsync(message *m_out);
void pm_reboot(void);
int do_svrctl(message *m_out);
-int do_getsysinfo(void);
+int do_getsysinfo(message *m_out);
int do_vm_call(message *m_out);
int pm_dumpcore(int sig, vir_bytes exe_name);
void ds_event(void);
no_sys, /* 74 = (sigprocmask) */
no_sys, /* 75 = (sigreturn) */
no_sys, /* 76 = (reboot) */
- do_svrctl, /* 77 = svrctl */
+ no_sys, /* 77 = (pm_svrctl) */
no_sys, /* 78 = (sysuname) */
no_sys, /* 79 = unused */
no_sys, /* 80 = unused */
no_sys, /* 120 = unsused */
no_sys, /* 121 = (task reply) */
do_mapdriver, /* 122 = mapdriver */
- do_getrusage, /* 123 = getrusage */
+ no_sys, /* 123 = (pm_getrusage) */
do_checkperms, /* 124 = checkperms */
+ no_sys, /* 125 = (pm_getsysinfo) */
+ do_getsysinfo, /* 126 = vfs_getsysinfo */
+ do_getrusage, /* 127 = vfs_getrusage */
+ do_svrctl, /* 128 = vfs_svrctl */
};
/* This should not fail with "array size is negative": */
extern int dummy[sizeof(call_vec) == NCALLS * sizeof(call_vec[0]) ? 1 : -1];