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 param;
unsigned long param;
endpoint_t proc_e = NONE;
struct sysgetenv sysgetenv;
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 <time.h>
#include <unistd.h>
#include <sys/svrctl.h>
#ifndef __minix_vmd
#include <sys/times.h>
#endif

View file

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

View file

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

View file

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

View file

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

View file

@ -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;

View file

@ -13,12 +13,15 @@ Created: Feb 15, 1994 by Philip Homburg <philip@cs.vu.nl>
#include <minix/ioctl.h>
/* 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 */

View file

@ -6,22 +6,19 @@
#include <string.h>
#include <sys/svrctl.h>
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;

View file

@ -8,7 +8,6 @@ Copyright 1995 Philip Homburg
#include <fcntl.h>
#include <unistd.h>
#include <sys/svrctl.h>
#include <minix/ds.h>
#include <minix/endpoint.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 "generic/assert.h"
#include <sys/svrctl.h>
#include "queryparam.h"
#include "generic/buf.h"

View file

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

View file

@ -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 >=

View file

@ -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: