]> Zhao Yanbai Git Server - minix.git/commitdiff
RS_LOOKUP feature for libc functions that want to access servers.
authorBen Gras <ben@minix3.org>
Mon, 21 Sep 2009 15:25:15 +0000 (15:25 +0000)
committerBen Gras <ben@minix3.org>
Mon, 21 Sep 2009 15:25:15 +0000 (15:25 +0000)
let ipc talk to all USER processes and vice versa.

pm sig wrapper notify has to be called from two files.

actually install include files.

etc/drivers.conf
include/Makefile
include/minix/com.h
servers/pm/proto.h
servers/pm/signal.c
servers/rs/main.c
servers/rs/manager.c
servers/rs/proto.h

index 382099585da0d83fa74f31db71601ce5112ee5fd..2e7b6639b12a48f65908c323531a4465a574e9d7 100644 (file)
@@ -395,6 +395,7 @@ driver ipc
                TTY
                DS
                VM
+               USER
                ;
        vm
                REMAP
index 7ee12e6383fa1985f3ae82ed98f69a30fa6e786f..5f71fc981755869e660483a45617c2dfded64e68 100644 (file)
@@ -8,11 +8,11 @@ all::
 clean::
 
 install::
-       #-rm -rf $(INC)
-       #mkdir -p $(INC)
-       #cpdir . $(INC)
-       #@chown -R bin $(INC)
-       #@rm -f $(INC)/Makefile
+       -rm -rf $(INC)
+       mkdir -p $(INC)
+       cpdir . $(INC)
+       @chown -R bin $(INC)
+       @rm -f $(INC)/Makefile
 
 gcc: install
        SHELL=/bin/sh; if [ -f $(MKHEADERS343) ] ; then sh -e $(MKHEADERS343) ; fi
index 202a79968eb7225b7b9472179353bb45de461458..ef8dc8f044075c68b8e294ad3edc930222b9029f 100755 (executable)
                                                 * arguments are passed in 
                                                 * a struct rs_start
                                                 */
-#define RS_LOOKUP      (DS_RQ_BASE + 8)        /* lookup server name */
+#define RS_LOOKUP      (RS_RQ_BASE + 8)        /* lookup server name */
 
 #  define RS_CMD_ADDR          m1_p1           /* command string */
 #  define RS_CMD_LEN           m1_i1           /* length of command */
index 3c091ea88c3966dc803e65be95935e46ea854909..b70f4837d2aa0269b69de37e6fe9c223c99c4993 100644 (file)
@@ -90,6 +90,8 @@ _PROTOTYPE( int do_sigprocmask, (void)                                        );
 _PROTOTYPE( int do_sigreturn, (void)                                   );
 _PROTOTYPE( int do_sigsuspend, (void)                                  );
 _PROTOTYPE( void check_pending, (struct mproc *rmp)                    );
+_PROTOTYPE( int, vm_notify_sig_wrapper(endpoint_t ep)                  ); 
+
 
 /* time.c */
 _PROTOTYPE( int do_stime, (void)                                       );
index c9244d2469c2788ece03ec2c075069f56ae13553..678945bbb6222fdcdce261d5b5fb6b57c8e8e0aa 100644 (file)
@@ -306,7 +306,7 @@ PUBLIC int do_pause()
   return(SUSPEND);
 }
 
-PRIVATE vm_notify_sig_wrapper(endpoint_t ep)
+PUBLIC vm_notify_sig_wrapper(endpoint_t ep)
 {
        /* get IPC's endpoint,
         * the reason that we directly get the endpoint
index 7808c380d8bc8920e59dd9a0f77af2e1333dfcb8..638065504fd3f5215d8f23131fc1d5afbf4f6df7 100644 (file)
@@ -91,9 +91,9 @@ PUBLIC int main(void)
                continue;
          }
 
-         /* Only root can make calls to rs */
+         /* Only root can make calls to rs. unless it's RS_LOOKUP. */
          euid= getpeuid(m.m_source);
-         if (euid != 0)
+         if (euid != 0 && call_nr != RS_LOOKUP)
          {
                printf("RS: got unauthorized request %d from endpoint %d\n",
                        call_nr, m.m_source);
@@ -111,6 +111,7 @@ PUBLIC int main(void)
           case RS_RESTART:     result = do_restart(&m);        break;
           case RS_SHUTDOWN:    result = do_shutdown(&m);       break;
           case GETSYSINFO:     result = do_getsysinfo(&m);     break;
+         case RS_LOOKUP:       result = do_lookup(&m);         break;
           default: 
               printf("Warning, RS got unexpected request %d from %d\n",
                   m.m_type, m.m_source);
index b08caeb5564d08e9fbada488ccf58e82d5e546c8..cd1ae0e37406caaf429dc4380cc02df90ba6319e 100644 (file)
@@ -14,6 +14,7 @@
 #include <minix/dmap.h>
 #include <minix/ds.h>
 #include <minix/endpoint.h>
+#include <minix/vm.h>
 #include <minix/rs.h>
 #include <lib.h>
 
@@ -1420,3 +1421,42 @@ int endpoint;
                return;
        }
 }
+
+/*===========================================================================*
+ *                             do_lookup                                    *
+ *===========================================================================*/
+PUBLIC int do_lookup(m_ptr)
+message *m_ptr;
+{
+       static char namebuf[100];
+       int len, r;
+       struct rproc *rrp;
+
+       len = m_ptr->RS_NAME_LEN;
+
+       if(len < 2 || len >= sizeof(namebuf)) {
+               printf("RS: len too weird (%d)\n", len);
+               return EINVAL;
+       }
+
+       if((r=sys_vircopy(m_ptr->m_source, D, (vir_bytes) m_ptr->RS_NAME,
+               SELF, D, (vir_bytes) namebuf, len)) != OK) {
+               printf("RS: name copy failed\n");
+               return r;
+
+       }
+
+       namebuf[len] = '\0';
+
+       for (rrp=BEG_RPROC_ADDR; rrp<END_RPROC_ADDR; rrp++) {
+               if (!(rrp->r_flags & RS_IN_USE))
+                       continue;
+               if (!strcmp(rrp->r_label, namebuf)) {
+                       m_ptr->RS_ENDPOINT = rrp->r_proc_nr_e;
+                       return OK;
+               }
+       }
+
+       return ESRCH;
+}
+
index 1e0ccf5e45817d7d31bb7101a656329ed0765360..583df7b0238e4c6a49bd4bd736454558b864a93f 100644 (file)
@@ -14,6 +14,7 @@ _PROTOTYPE( int do_down, (message *m));
 _PROTOTYPE( int do_refresh, (message *m));
 _PROTOTYPE( int do_rescue, (message *m));
 _PROTOTYPE( int do_restart, (message *m));
+_PROTOTYPE( int do_lookup, (message *m));
 _PROTOTYPE( int do_shutdown, (message *m));
 _PROTOTYPE( void do_period, (message *m));
 _PROTOTYPE( void do_exit, (message *m));