From f737eea6368426d3302d0075f13f73c4bc646e24 Mon Sep 17 00:00:00 2001 From: David van Moolenbroek Date: Mon, 29 Sep 2014 15:41:36 +0000 Subject: [PATCH] svrctl(2) update - synchronize request type with ioctl by making it unsigned long; - unbreak VFS requests, as they were being sent to PM; - use proper ioctl direction flags (and new numbers) for requests; - remove some needless header inclusions; - svrctl is in libc, make its message name reflect this; - keep backward compatibility: svrctl is part of the userland ABI. Change-Id: I44902e8d0d11b8ebc1ef3bda94d2202481743c9b --- minix/commands/svrctl/svrctl.c | 2 +- minix/commands/tcpstat/tcpstat.c | 1 - minix/commands/udpstat/udpstat.c | 1 - .../clock/readclock/arch/i386/arch_readclock.c | 1 - minix/drivers/clock/readclock/readclock.c | 1 - minix/drivers/storage/at_wini/at_wini.c | 1 - minix/include/minix/ipc.h | 18 +++++++++--------- minix/include/sys/svrctl.h | 13 ++++++++----- minix/lib/libc/sys/svrctl.c | 17 +++++++---------- minix/net/inet/inet.c | 1 - minix/net/inet/qp.c | 1 - minix/net/lwip/lwip.c | 1 - minix/servers/pm/misc.c | 17 ++++++++++------- minix/servers/vfs/misc.c | 9 +++++---- 14 files changed, 40 insertions(+), 44 deletions(-) diff --git a/minix/commands/svrctl/svrctl.c b/minix/commands/svrctl/svrctl.c index 820fe3891..e9c2280de 100644 --- a/minix/commands/svrctl/svrctl.c +++ b/minix/commands/svrctl/svrctl.c @@ -20,7 +20,7 @@ static char *bin_name; int main (int argc, char *argv[]) { - int param; + unsigned long param; endpoint_t proc_e = NONE; struct sysgetenv sysgetenv; char *to_whom, *operation, *what, *value; diff --git a/minix/commands/tcpstat/tcpstat.c b/minix/commands/tcpstat/tcpstat.c index f5200a456..2ea8e4fca 100644 --- a/minix/commands/tcpstat/tcpstat.c +++ b/minix/commands/tcpstat/tcpstat.c @@ -15,7 +15,6 @@ Created: June 1995 by Philip Homburg #include #include #include -#include #ifndef __minix_vmd #include #endif diff --git a/minix/commands/udpstat/udpstat.c b/minix/commands/udpstat/udpstat.c index 54c1c73d1..e893b6c73 100644 --- a/minix/commands/udpstat/udpstat.c +++ b/minix/commands/udpstat/udpstat.c @@ -16,7 +16,6 @@ Created: March 2001 by Philip Homburg #include #include #include -#include #ifndef __minix_vmd #include #endif diff --git a/minix/drivers/clock/readclock/arch/i386/arch_readclock.c b/minix/drivers/clock/readclock/arch/i386/arch_readclock.c index 9d6b5bd64..07efbca69 100644 --- a/minix/drivers/clock/readclock/arch/i386/arch_readclock.c +++ b/minix/drivers/clock/readclock/arch/i386/arch_readclock.c @@ -51,7 +51,6 @@ #include #include #include -#include #include "readclock.h" diff --git a/minix/drivers/clock/readclock/readclock.c b/minix/drivers/clock/readclock/readclock.c index 335f4ffac..2435f2742 100644 --- a/minix/drivers/clock/readclock/readclock.c +++ b/minix/drivers/clock/readclock/readclock.c @@ -16,7 +16,6 @@ #include #include #include -#include #include "readclock.h" diff --git a/minix/drivers/storage/at_wini/at_wini.c b/minix/drivers/storage/at_wini/at_wini.c index 2bfc26a38..c8490e0a8 100644 --- a/minix/drivers/storage/at_wini/at_wini.c +++ b/minix/drivers/storage/at_wini/at_wini.c @@ -19,7 +19,6 @@ #include #include #include -#include /* Variables. */ diff --git a/minix/include/minix/ipc.h b/minix/include/minix/ipc.h index 074c46ba3..3df54efc2 100644 --- a/minix/include/minix/ipc.h +++ b/minix/include/minix/ipc.h @@ -596,6 +596,14 @@ typedef struct { } mess_lc_readclock_rtcdev; _ASSERT_MSG_SIZE(mess_lc_readclock_rtcdev); +typedef struct { + unsigned long request; + vir_bytes arg; + + uint8_t padding[48]; +} mess_lc_svrctl; +_ASSERT_MSG_SIZE(mess_lc_svrctl); + typedef struct { vir_bytes name; size_t len; @@ -1314,14 +1322,6 @@ typedef struct { } mess_lsys_sched_scheduling_stop; _ASSERT_MSG_SIZE(mess_lsys_sched_scheduling_stop); -typedef struct { - int request; - vir_bytes arg; - - uint8_t padding[48]; -} mess_lsys_svrctl; -_ASSERT_MSG_SIZE(mess_lsys_svrctl); - typedef struct { int request; int fkeys; @@ -2095,6 +2095,7 @@ typedef struct { mess_lc_pm_time m_lc_pm_time; mess_lc_pm_waitpid m_lc_pm_waitpid; mess_lc_readclock_rtcdev m_lc_readclock_rtcdev; + mess_lc_svrctl m_lc_svrctl; mess_lc_vfs_chown m_lc_vfs_chown; mess_lc_vfs_close m_lc_vfs_close; mess_lc_vfs_creat m_lc_vfs_creat; @@ -2174,7 +2175,6 @@ typedef struct { mess_lsys_pm_srv_fork m_lsys_pm_srv_fork; mess_lsys_sched_scheduling_start m_lsys_sched_scheduling_start; mess_lsys_sched_scheduling_stop m_lsys_sched_scheduling_stop; - mess_lsys_svrctl m_lsys_svrctl; mess_lsys_tty_fkey_ctl m_lsys_tty_fkey_ctl; mess_lsys_vfs_checkperms m_lsys_vfs_checkperms; mess_lsys_vfs_copyfd m_lsys_vfs_copyfd; diff --git a/minix/include/sys/svrctl.h b/minix/include/sys/svrctl.h index 88746d4b1..4b189444f 100644 --- a/minix/include/sys/svrctl.h +++ b/minix/include/sys/svrctl.h @@ -13,12 +13,15 @@ Created: Feb 15, 1994 by Philip Homburg #include /* PM controls. */ -#define PMGETPARAM _IOW('M', 5, struct sysgetenv) -#define PMSETPARAM _IOR('M', 7, struct sysgetenv) +#define PMGETPARAM _IOWR('P', 0, struct sysgetenv) +#define PMSETPARAM _IOW('P', 1, struct sysgetenv) + +#define OPMGETPARAM _IOW('M', 5, struct sysgetenv) /* old, phasing out */ +#define OPMSETPARAM _IOR('M', 7, struct sysgetenv) /* old, phasing out */ /* VFS controls */ -#define VFSSETPARAM _IOR('M', 130, struct sysgetenv) -#define VFSGETPARAM _IOR('M', 131, struct sysgetenv) +#define VFSGETPARAM _IOWR('F', 0, struct sysgetenv) +#define VFSSETPARAM _IOW('F', 1, struct sysgetenv) struct sysgetenv { char *key; /* Name requested. */ @@ -27,6 +30,6 @@ struct sysgetenv { size_t vallen; /* Size of return data buffer. */ }; -int svrctl(int _request, void *_data); +int svrctl(unsigned long _request, void *_data); #endif /* _SYS__SVRCTL_H */ diff --git a/minix/lib/libc/sys/svrctl.c b/minix/lib/libc/sys/svrctl.c index b93af6cea..67649f853 100644 --- a/minix/lib/libc/sys/svrctl.c +++ b/minix/lib/libc/sys/svrctl.c @@ -6,22 +6,19 @@ #include #include -int svrctl(int request, void *argp) +int svrctl(unsigned long request, void *argp) { message m; memset(&m, 0, sizeof(m)); - m.m_lsys_svrctl.request = request; - m.m_lsys_svrctl.arg = argp; + m.m_lc_svrctl.request = request; + m.m_lc_svrctl.arg = (vir_bytes)argp; - switch ((request >> 8) & 0xFF) { - case 'M': - case 'S': - /* PM handles calls for itself and the kernel. */ + switch (IOCGROUP(request)) { + case 'M': /* old, phasing out */ + case 'P': /* to PM */ return _syscall(PM_PROC_NR, PM_SVRCTL, &m); - case 'F': - case 'I': - /* VFS handles calls for itself and inet. */ + case 'F': /* to VFS */ return _syscall(VFS_PROC_NR, VFS_SVRCTL, &m); default: errno = EINVAL; diff --git a/minix/net/inet/inet.c b/minix/net/inet/inet.c index c18dd58cc..1c6aecb67 100644 --- a/minix/net/inet/inet.c +++ b/minix/net/inet/inet.c @@ -8,7 +8,6 @@ Copyright 1995 Philip Homburg #include #include -#include #include #include #include diff --git a/minix/net/inet/qp.c b/minix/net/inet/qp.c index df09c856b..7350a0931 100644 --- a/minix/net/inet/qp.c +++ b/minix/net/inet/qp.c @@ -9,7 +9,6 @@ Created: June 1995 by Philip Homburg #include "inet.h" #include "generic/assert.h" -#include #include "queryparam.h" #include "generic/buf.h" diff --git a/minix/net/lwip/lwip.c b/minix/net/lwip/lwip.c index 0edd7af51..f7b5af051 100644 --- a/minix/net/lwip/lwip.c +++ b/minix/net/lwip/lwip.c @@ -1,6 +1,5 @@ #include #include -#include #include #include #include diff --git a/minix/servers/pm/misc.c b/minix/servers/pm/misc.c index 8014f63d7..0b594376f 100644 --- a/minix/servers/pm/misc.c +++ b/minix/servers/pm/misc.c @@ -295,9 +295,10 @@ int do_getsetpriority() /*===========================================================================* * do_svrctl * *===========================================================================*/ -int do_svrctl() +int do_svrctl(void) { - int s, req; + unsigned long req; + int s; vir_bytes ptr; #define MAX_LOCAL_PARAMS 2 static struct { @@ -306,14 +307,16 @@ int do_svrctl() } local_param_overrides[MAX_LOCAL_PARAMS]; static int local_params = 0; - req = m_in.m_lsys_svrctl.request; - ptr = m_in.m_lsys_svrctl.arg; + req = m_in.m_lc_svrctl.request; + ptr = m_in.m_lc_svrctl.arg; - /* Is the request indeed for the PM? */ - if (((req >> 8) & 0xFF) != 'M') return(EINVAL); + /* Is the request indeed for the PM? ('M' is old and being phased out) */ + if (IOCGROUP(req) != 'P' && IOCGROUP(req) != 'M') return(EINVAL); /* Control operations local to the PM. */ switch(req) { + case OPMSETPARAM: + case OPMGETPARAM: case PMSETPARAM: case PMGETPARAM: { struct sysgetenv sysgetenv; @@ -327,7 +330,7 @@ int do_svrctl() sizeof(sysgetenv)) != OK) return(EFAULT); /* Set a param override? */ - if (req == PMSETPARAM) { + if (req == PMSETPARAM || req == OPMSETPARAM) { if (local_params >= MAX_LOCAL_PARAMS) return ENOSPC; if (sysgetenv.keylen <= 0 || sysgetenv.keylen >= diff --git a/minix/servers/vfs/misc.c b/minix/servers/vfs/misc.c index 65d4b8630..8652007ca 100644 --- a/minix/servers/vfs/misc.c +++ b/minix/servers/vfs/misc.c @@ -776,12 +776,13 @@ void pm_setsid(endpoint_t proc_e) *===========================================================================*/ int do_svrctl(void) { - unsigned int svrctl; + unsigned long svrctl; vir_bytes ptr; - svrctl = job_m_in.m_lsys_svrctl.request; - ptr = job_m_in.m_lsys_svrctl.arg; - if (((svrctl >> 8) & 0xFF) != 'M') return(EINVAL); + svrctl = job_m_in.m_lc_svrctl.request; + ptr = job_m_in.m_lc_svrctl.arg; + + if (IOCGROUP(svrctl) != 'F') return(EINVAL); switch (svrctl) { case VFSSETPARAM: -- 2.44.0