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
This commit is contained in:
David van Moolenbroek 2014-09-29 15:41:36 +00:00
parent 347cc10a91
commit f737eea636
14 changed files with 40 additions and 44 deletions

View file

@ -20,7 +20,7 @@ static char *bin_name;
int main (int argc, char *argv[]) int main (int argc, char *argv[])
{ {
int param; unsigned long param;
endpoint_t proc_e = NONE; endpoint_t proc_e = NONE;
struct sysgetenv sysgetenv; struct sysgetenv sysgetenv;
char *to_whom, *operation, *what, *value; char *to_whom, *operation, *what, *value;

View file

@ -15,7 +15,6 @@ Created: June 1995 by Philip Homburg <philip@f-mnx.phicoh.com>
#include <stdio.h> #include <stdio.h>
#include <time.h> #include <time.h>
#include <unistd.h> #include <unistd.h>
#include <sys/svrctl.h>
#ifndef __minix_vmd #ifndef __minix_vmd
#include <sys/times.h> #include <sys/times.h>
#endif #endif

View file

@ -16,7 +16,6 @@ Created: March 2001 by Philip Homburg <philip@f-mnx.phicoh.com>
#include <stdio.h> #include <stdio.h>
#include <time.h> #include <time.h>
#include <unistd.h> #include <unistd.h>
#include <sys/svrctl.h>
#ifndef __minix_vmd #ifndef __minix_vmd
#include <sys/times.h> #include <sys/times.h>
#endif #endif

View file

@ -51,7 +51,6 @@
#include <minix/com.h> #include <minix/com.h>
#include <minix/log.h> #include <minix/log.h>
#include <machine/cmos.h> #include <machine/cmos.h>
#include <sys/svrctl.h>
#include "readclock.h" #include "readclock.h"

View file

@ -16,7 +16,6 @@
#include <minix/com.h> #include <minix/com.h>
#include <minix/type.h> #include <minix/type.h>
#include <minix/safecopies.h> #include <minix/safecopies.h>
#include <sys/svrctl.h>
#include "readclock.h" #include "readclock.h"

View file

@ -19,7 +19,6 @@
#include <sys/ioc_disk.h> #include <sys/ioc_disk.h>
#include <machine/pci.h> #include <machine/pci.h>
#include <sys/mman.h> #include <sys/mman.h>
#include <sys/svrctl.h>
/* Variables. */ /* Variables. */

View file

@ -596,6 +596,14 @@ typedef struct {
} mess_lc_readclock_rtcdev; } mess_lc_readclock_rtcdev;
_ASSERT_MSG_SIZE(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 { typedef struct {
vir_bytes name; vir_bytes name;
size_t len; size_t len;
@ -1314,14 +1322,6 @@ typedef struct {
} mess_lsys_sched_scheduling_stop; } mess_lsys_sched_scheduling_stop;
_ASSERT_MSG_SIZE(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 { typedef struct {
int request; int request;
int fkeys; int fkeys;
@ -2095,6 +2095,7 @@ typedef struct {
mess_lc_pm_time m_lc_pm_time; mess_lc_pm_time m_lc_pm_time;
mess_lc_pm_waitpid m_lc_pm_waitpid; mess_lc_pm_waitpid m_lc_pm_waitpid;
mess_lc_readclock_rtcdev m_lc_readclock_rtcdev; 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_chown m_lc_vfs_chown;
mess_lc_vfs_close m_lc_vfs_close; mess_lc_vfs_close m_lc_vfs_close;
mess_lc_vfs_creat m_lc_vfs_creat; 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_pm_srv_fork m_lsys_pm_srv_fork;
mess_lsys_sched_scheduling_start m_lsys_sched_scheduling_start; mess_lsys_sched_scheduling_start m_lsys_sched_scheduling_start;
mess_lsys_sched_scheduling_stop m_lsys_sched_scheduling_stop; 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_tty_fkey_ctl m_lsys_tty_fkey_ctl;
mess_lsys_vfs_checkperms m_lsys_vfs_checkperms; mess_lsys_vfs_checkperms m_lsys_vfs_checkperms;
mess_lsys_vfs_copyfd m_lsys_vfs_copyfd; mess_lsys_vfs_copyfd m_lsys_vfs_copyfd;

View file

@ -13,12 +13,15 @@ Created: Feb 15, 1994 by Philip Homburg <philip@cs.vu.nl>
#include <minix/ioctl.h> #include <minix/ioctl.h>
/* PM controls. */ /* PM controls. */
#define PMGETPARAM _IOW('M', 5, struct sysgetenv) #define PMGETPARAM _IOWR('P', 0, struct sysgetenv)
#define PMSETPARAM _IOR('M', 7, 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 */ /* VFS controls */
#define VFSSETPARAM _IOR('M', 130, struct sysgetenv) #define VFSGETPARAM _IOWR('F', 0, struct sysgetenv)
#define VFSGETPARAM _IOR('M', 131, struct sysgetenv) #define VFSSETPARAM _IOW('F', 1, struct sysgetenv)
struct sysgetenv { struct sysgetenv {
char *key; /* Name requested. */ char *key; /* Name requested. */
@ -27,6 +30,6 @@ struct sysgetenv {
size_t vallen; /* Size of return data buffer. */ 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 */ #endif /* _SYS__SVRCTL_H */

View file

@ -6,22 +6,19 @@
#include <string.h> #include <string.h>
#include <sys/svrctl.h> #include <sys/svrctl.h>
int svrctl(int request, void *argp) int svrctl(unsigned long request, void *argp)
{ {
message m; message m;
memset(&m, 0, sizeof(m)); memset(&m, 0, sizeof(m));
m.m_lsys_svrctl.request = request; m.m_lc_svrctl.request = request;
m.m_lsys_svrctl.arg = argp; m.m_lc_svrctl.arg = (vir_bytes)argp;
switch ((request >> 8) & 0xFF) { switch (IOCGROUP(request)) {
case 'M': case 'M': /* old, phasing out */
case 'S': case 'P': /* to PM */
/* PM handles calls for itself and the kernel. */
return _syscall(PM_PROC_NR, PM_SVRCTL, &m); return _syscall(PM_PROC_NR, PM_SVRCTL, &m);
case 'F': case 'F': /* to VFS */
case 'I':
/* VFS handles calls for itself and inet. */
return _syscall(VFS_PROC_NR, VFS_SVRCTL, &m); return _syscall(VFS_PROC_NR, VFS_SVRCTL, &m);
default: default:
errno = EINVAL; errno = EINVAL;

View file

@ -8,7 +8,6 @@ Copyright 1995 Philip Homburg
#include <fcntl.h> #include <fcntl.h>
#include <unistd.h> #include <unistd.h>
#include <sys/svrctl.h>
#include <minix/ds.h> #include <minix/ds.h>
#include <minix/endpoint.h> #include <minix/endpoint.h>
#include <minix/chardriver.h> #include <minix/chardriver.h>

View file

@ -9,7 +9,6 @@ Created: June 1995 by Philip Homburg <philip@f-mnx.phicoh.com>
#include "inet.h" #include "inet.h"
#include "generic/assert.h" #include "generic/assert.h"
#include <sys/svrctl.h>
#include "queryparam.h" #include "queryparam.h"
#include "generic/buf.h" #include "generic/buf.h"

View file

@ -1,6 +1,5 @@
#include <unistd.h> #include <unistd.h>
#include <minix/timers.h> #include <minix/timers.h>
#include <sys/svrctl.h>
#include <minix/ds.h> #include <minix/ds.h>
#include <minix/endpoint.h> #include <minix/endpoint.h>
#include <errno.h> #include <errno.h>

View file

@ -295,9 +295,10 @@ int do_getsetpriority()
/*===========================================================================* /*===========================================================================*
* do_svrctl * * do_svrctl *
*===========================================================================*/ *===========================================================================*/
int do_svrctl() int do_svrctl(void)
{ {
int s, req; unsigned long req;
int s;
vir_bytes ptr; vir_bytes ptr;
#define MAX_LOCAL_PARAMS 2 #define MAX_LOCAL_PARAMS 2
static struct { static struct {
@ -306,14 +307,16 @@ int do_svrctl()
} local_param_overrides[MAX_LOCAL_PARAMS]; } local_param_overrides[MAX_LOCAL_PARAMS];
static int local_params = 0; static int local_params = 0;
req = m_in.m_lsys_svrctl.request; req = m_in.m_lc_svrctl.request;
ptr = m_in.m_lsys_svrctl.arg; ptr = m_in.m_lc_svrctl.arg;
/* Is the request indeed for the PM? */ /* Is the request indeed for the PM? ('M' is old and being phased out) */
if (((req >> 8) & 0xFF) != 'M') return(EINVAL); if (IOCGROUP(req) != 'P' && IOCGROUP(req) != 'M') return(EINVAL);
/* Control operations local to the PM. */ /* Control operations local to the PM. */
switch(req) { switch(req) {
case OPMSETPARAM:
case OPMGETPARAM:
case PMSETPARAM: case PMSETPARAM:
case PMGETPARAM: { case PMGETPARAM: {
struct sysgetenv sysgetenv; struct sysgetenv sysgetenv;
@ -327,7 +330,7 @@ int do_svrctl()
sizeof(sysgetenv)) != OK) return(EFAULT); sizeof(sysgetenv)) != OK) return(EFAULT);
/* Set a param override? */ /* Set a param override? */
if (req == PMSETPARAM) { if (req == PMSETPARAM || req == OPMSETPARAM) {
if (local_params >= MAX_LOCAL_PARAMS) return ENOSPC; if (local_params >= MAX_LOCAL_PARAMS) return ENOSPC;
if (sysgetenv.keylen <= 0 if (sysgetenv.keylen <= 0
|| sysgetenv.keylen >= || sysgetenv.keylen >=

View file

@ -776,12 +776,13 @@ void pm_setsid(endpoint_t proc_e)
*===========================================================================*/ *===========================================================================*/
int do_svrctl(void) int do_svrctl(void)
{ {
unsigned int svrctl; unsigned long svrctl;
vir_bytes ptr; vir_bytes ptr;
svrctl = job_m_in.m_lsys_svrctl.request; svrctl = job_m_in.m_lc_svrctl.request;
ptr = job_m_in.m_lsys_svrctl.arg; ptr = job_m_in.m_lc_svrctl.arg;
if (((svrctl >> 8) & 0xFF) != 'M') return(EINVAL);
if (IOCGROUP(svrctl) != 'F') return(EINVAL);
switch (svrctl) { switch (svrctl) {
case VFSSETPARAM: case VFSSETPARAM: