From: David van Moolenbroek Date: Sun, 6 Sep 2009 12:37:13 +0000 (+0000) Subject: - sys_privctl: don't mix message types X-Git-Tag: v3.1.5~156 X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/zpipe.c?a=commitdiff_plain;h=979bcfc1956e1933a555b76d9cf71e35e5d2b47b;p=minix.git - sys_privctl: don't mix message types - sys_privctl: remove CTL_MM_PRIV (third parameter) - remove obsolete sys_svrctl.c library file --- diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index daa2f7181..c346b8764 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -316,7 +316,7 @@ int devind; int proc; { int i, r; - u8_t ilr; + int ilr; struct io_range ior; struct mem_range mr; @@ -348,7 +348,7 @@ int proc; "pci_reserve3: for proc %d, adding I/O range [0x%x..0x%x]\n", proc, ior.ior_base, ior.ior_limit); } - r= sys_privctl(proc, SYS_PRIV_ADD_IO, 0, &ior); + r= sys_privctl(proc, SYS_PRIV_ADD_IO, &ior); if (r != OK) { printf("sys_privctl failed for proc %d: %d\n", @@ -366,7 +366,7 @@ int proc; "pci_reserve3: for proc %d, should add memory range [0x%x..0x%x]\n", proc, mr.mr_base, mr.mr_limit); } - r= sys_privctl(proc, SYS_PRIV_ADD_MEM, 0, &mr); + r= sys_privctl(proc, SYS_PRIV_ADD_MEM, &mr); if (r != OK) { printf("sys_privctl failed for proc %d: %d\n", @@ -378,7 +378,7 @@ int proc; if (ilr != PCI_ILR_UNKNOWN) { if(debug) printf("pci_reserve3: adding IRQ %d\n", ilr); - r= sys_privctl(proc, SYS_PRIV_ADD_IRQ, ilr, NULL); + r= sys_privctl(proc, SYS_PRIV_ADD_IRQ, &ilr); if (r != OK) { printf("sys_privctl failed for proc %d: %d\n", diff --git a/include/minix/com.h b/include/minix/com.h index 4402fa760..b13d7e65d 100755 --- a/include/minix/com.h +++ b/include/minix/com.h @@ -493,7 +493,6 @@ /* Field names for SYS_TRACE, SYS_PRIVCTL. */ #define CTL_ENDPT m2_i1 /* process number of the caller */ #define CTL_REQUEST m2_i2 /* server control request */ -#define CTL_MM_PRIV m2_i3 /* privilege as seen by PM */ #define CTL_ARG_PTR m2_p1 /* pointer to argument */ #define CTL_ADDRESS m2_l1 /* address at traced process' space */ #define CTL_DATA m2_l2 /* data field for tracing */ diff --git a/include/minix/syslib.h b/include/minix/syslib.h index 9b51b76ac..8af499dc5 100755 --- a/include/minix/syslib.h +++ b/include/minix/syslib.h @@ -40,7 +40,7 @@ _PROTOTYPE( int sys_newmap, (endpoint_t proc, struct mem_map *ptr)); _PROTOTYPE( int sys_exit, (endpoint_t proc)); _PROTOTYPE( int sys_trace, (int req, endpoint_t proc, long addr, long *data_p)); -_PROTOTYPE( int sys_privctl, (endpoint_t proc, int req, int i, void *p)); +_PROTOTYPE( int sys_privctl, (endpoint_t proc, int req, void *p)); _PROTOTYPE( int sys_setgrant, (cp_grant_t *grants, int ngrants)); _PROTOTYPE( int sys_nice, (endpoint_t proc, int priority)); diff --git a/kernel/system/do_privctl.c b/kernel/system/do_privctl.c index 175da2bf7..a44201f5c 100644 --- a/kernel/system/do_privctl.c +++ b/kernel/system/do_privctl.c @@ -2,7 +2,9 @@ * m_type: SYS_PRIVCTL * * The parameters for this kernel call are: - * m1_i1: PR_ENDPT (process number of caller) + * m2_i1: CTL_ENDPT (process endpoint of target) + * m2_i2: CTL_REQUEST (privilege control request) + * m2_p1: CTL_ARG_PTR (pointer to request data) */ #include "../system.h" @@ -32,6 +34,7 @@ message *m_ptr; /* pointer to request message */ struct io_range io_range; struct mem_range mem_range; struct priv priv; + int irq; /* Check whether caller is allowed to make this call. Privileged proceses * can only update the privileges of processes that are inhibited from @@ -40,8 +43,8 @@ message *m_ptr; /* pointer to request message */ */ caller_ptr = proc_addr(who_p); if (! (priv(caller_ptr)->s_flags & SYS_PROC)) return(EPERM); - if(m_ptr->PR_ENDPT == SELF) proc_nr = who_p; - else if(!isokendpt(m_ptr->PR_ENDPT, &proc_nr)) return(EINVAL); + if(m_ptr->CTL_ENDPT == SELF) proc_nr = who_p; + else if(!isokendpt(m_ptr->CTL_ENDPT, &proc_nr)) return(EINVAL); rp = proc_addr(proc_nr); switch(m_ptr->CTL_REQUEST) @@ -216,12 +219,14 @@ message *m_ptr; /* pointer to request message */ if (!(priv(rp)->s_flags & SYS_PROC)) return EPERM; + data_copy(who_e, (vir_bytes) m_ptr->CTL_ARG_PTR, + SYSTEM, (vir_bytes) &irq, sizeof(irq)); priv(rp)->s_flags |= CHECK_IRQ; /* Check IRQs */ i= priv(rp)->s_nr_irq; if (i >= NR_IRQ) return ENOMEM; - priv(rp)->s_irq_tab[i]= m_ptr->CTL_MM_PRIV; + priv(rp)->s_irq_tab[i]= irq; priv(rp)->s_nr_irq++; return OK; diff --git a/lib/syslib/sys_privctl.c b/lib/syslib/sys_privctl.c index 9c14aa5c8..71a1bee1c 100644 --- a/lib/syslib/sys_privctl.c +++ b/lib/syslib/sys_privctl.c @@ -1,12 +1,11 @@ #include "syslib.h" -int sys_privctl(int proc, int request, int i, void *p) +int sys_privctl(endpoint_t proc, int request, void *p) { message m; m.CTL_ENDPT = proc; m.CTL_REQUEST = request; - m.CTL_MM_PRIV = i; m.CTL_ARG_PTR = p; return _taskcall(SYSTASK, SYS_PRIVCTL, &m); diff --git a/lib/syslib/sys_svrctl.c b/lib/syslib/sys_svrctl.c deleted file mode 100644 index 7fc8ad130..000000000 --- a/lib/syslib/sys_svrctl.c +++ /dev/null @@ -1,13 +0,0 @@ -#include "syslib.h" - -int sys_svrctl(int proc, int request, int priv, vir_bytes argp) -{ - message m; - - m.CTL_ENDPT = proc; - m.CTL_REQUEST = request; - m.CTL_MM_PRIV = priv; - m.CTL_ARG_PTR = (char *) argp; - - return _taskcall(SYSTASK, SYS_PRIVCTL, &m); -} diff --git a/servers/rs/manager.c b/servers/rs/manager.c index 49b4f17f4..884f36480 100644 --- a/servers/rs/manager.c +++ b/servers/rs/manager.c @@ -855,7 +855,7 @@ endpoint_t *endpoint; /* Set the privilege structure for the child process to let is run. * This should succeed: we tested number in use above. */ - if ((s = sys_privctl(child_proc_nr_e, SYS_PRIV_INIT, 0, privp)) < 0) { + if ((s = sys_privctl(child_proc_nr_e, SYS_PRIV_INIT, privp)) < 0) { report("RS","sys_privctl call failed", s); /* to let child run */ rp->r_flags |= RS_EXITING; /* expect exit */ if(child_pid > 0) kill(child_pid, SIGKILL); /* kill driver */ @@ -1080,7 +1080,7 @@ struct rproc *rp; * run. */ proc_nr_e = getnprocnr(pid); - r= sys_privctl(proc_nr_e, SYS_PRIV_USER, 0, NULL); + r= sys_privctl(proc_nr_e, SYS_PRIV_USER, NULL); if (r < 0) printf("RS: run_script: sys_privctl call failed: %d\n", r);