diff --git a/commands/svrctl/svrctl.c b/commands/svrctl/svrctl.c index 6338281c3..a481eabc1 100644 --- a/commands/svrctl/svrctl.c +++ b/commands/svrctl/svrctl.c @@ -18,10 +18,9 @@ static char *bin_name; 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; @@ -60,10 +59,7 @@ int main (int argc, char *argv[]) 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) @@ -87,10 +83,7 @@ int main (int argc, char *argv[]) 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 diff --git a/include/minix/callnr.h b/include/minix/callnr.h index 9914aafa8..32c5c3a34 100644 --- a/include/minix/callnr.h +++ b/include/minix/callnr.h @@ -1,4 +1,4 @@ -#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 @@ -66,7 +66,7 @@ #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 */ @@ -106,6 +106,11 @@ #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 */ diff --git a/include/minix/com.h b/include/minix/com.h index 1638dc568..c24df0c70 100644 --- a/include/minix/com.h +++ b/include/minix/com.h @@ -648,6 +648,8 @@ #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 */ @@ -683,6 +685,7 @@ #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 */ @@ -816,11 +819,10 @@ # 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 */ diff --git a/lib/libc/sys-minix/getrusage.c b/lib/libc/sys-minix/getrusage.c index 271eb241b..6c983d778 100644 --- a/lib/libc/sys-minix/getrusage.c +++ b/lib/libc/sys-minix/getrusage.c @@ -22,10 +22,10 @@ int getrusage(int who, struct rusage *r_usage) } 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); diff --git a/lib/libminlib/svrctl.c b/lib/libminlib/svrctl.c index 6d4578c56..e0f43948f 100644 --- a/lib/libminlib/svrctl.c +++ b/lib/libminlib/svrctl.c @@ -16,11 +16,11 @@ int svrctl(int request, void *argp) 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; diff --git a/lib/libsys/getsysinfo.c b/lib/libsys/getsysinfo.c index 27d0ff3e8..a5a4fbc7d 100644 --- a/lib/libsys/getsysinfo.c +++ b/lib/libsys/getsysinfo.c @@ -1,5 +1,6 @@ #include "syslib.h" + #include #include #include @@ -12,9 +13,20 @@ int getsysinfo( ) { 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); } diff --git a/servers/ds/main.c b/servers/ds/main.c index a135f8f90..1d684dcf8 100644 --- a/servers/ds/main.c +++ b/servers/ds/main.c @@ -69,7 +69,7 @@ int main(int argc, char **argv) case DS_CHECK: result = do_check(&m); break; - case COMMON_GETSYSINFO: + case DS_GETSYSINFO: result = do_getsysinfo(&m); break; default: diff --git a/servers/pm/main.c b/servers/pm/main.c index 141333692..6f1e03810 100644 --- a/servers/pm/main.c +++ b/servers/pm/main.c @@ -116,9 +116,6 @@ 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. diff --git a/servers/pm/table.c b/servers/pm/table.c index b84c1ff44..d352b18b1 100644 --- a/servers/pm/table.c +++ b/servers/pm/table.c @@ -88,7 +88,7 @@ int (*call_vec[])(void) = { 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) */ @@ -134,8 +134,12 @@ int (*call_vec[])(void) = { 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]; diff --git a/servers/rs/main.c b/servers/rs/main.c index 5b1ddcc4c..7488b4366 100644 --- a/servers/rs/main.c +++ b/servers/rs/main.c @@ -93,15 +93,6 @@ int main(void) * 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. */ @@ -113,8 +104,7 @@ 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 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; @@ -122,7 +112,7 @@ int main(void) 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. */ diff --git a/servers/vfs/main.c b/servers/vfs/main.c index d99f39ec3..c8433ca45 100644 --- a/servers/vfs/main.c +++ b/servers/vfs/main.c @@ -233,27 +233,23 @@ static void do_work(void) 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. */ diff --git a/servers/vfs/misc.c b/servers/vfs/misc.c index 81e2df697..058abb324 100644 --- a/servers/vfs/misc.c +++ b/servers/vfs/misc.c @@ -51,7 +51,7 @@ static void free_proc(int flags); /*===========================================================================* * do_getsysinfo * *===========================================================================*/ -int do_getsysinfo() +int do_getsysinfo(message *UNUSED(m_out)) { vir_bytes src_addr, dst_addr; size_t len, buf_size; diff --git a/servers/vfs/proto.h b/servers/vfs/proto.h index 06e873b0d..89f8b2c3f 100644 --- a/servers/vfs/proto.h +++ b/servers/vfs/proto.h @@ -115,7 +115,7 @@ int do_sync(message *m_out); 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); diff --git a/servers/vfs/table.c b/servers/vfs/table.c index 9a8beb285..1abf53e9b 100644 --- a/servers/vfs/table.c +++ b/servers/vfs/table.c @@ -91,7 +91,7 @@ int (*call_vec[])(message *m_out) = { 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 */ @@ -137,8 +137,12 @@ int (*call_vec[])(message *m_out) = { 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];