]> Zhao Yanbai Git Server - minix.git/commitdiff
VFS: enable sending control messages
authorThomas Veerman <thomas@minix3.org>
Fri, 30 Mar 2012 09:24:44 +0000 (09:24 +0000)
committerThomas Veerman <thomas@minix3.org>
Fri, 13 Apr 2012 12:54:55 +0000 (12:54 +0000)
common/include/sys/svrctl.h
servers/vfs/glo.h
servers/vfs/main.c
servers/vfs/misc.c

index 2d1f69bdfef0eba47926a4e4510253b3dce4dda7..1bdad0e331fc9bb171ca1763e75e69f5998b7d33 100644 (file)
@@ -18,6 +18,10 @@ Created:     Feb 15, 1994 by Philip Homburg <philip@cs.vu.nl>
 #define PMGETPARAM     _IOW('M',  5, struct sysgetenv)
 #define PMSETPARAM     _IOR('M',  7, struct sysgetenv)
 
+/* VFS controls */
+#define VFSSETPARAM    _IOR('M', 130, struct sysgetenv)
+#define VFSGETPARAM    _IOR('M', 131, struct sysgetenv)
+
 struct sysgetenv {
        char            *key;           /* Name requested. */
        size_t          keylen;         /* Length of name including \0. */
index e2603ae624fc25e5e3fb829258a118dac6f907f8..ac35c6d942555337d9a144bb10a4c3680ccdeeb4 100644 (file)
@@ -14,6 +14,7 @@ EXTERN int nr_locks;          /* number of locks currently in place */
 EXTERN int reviving;           /* number of pipe processes to be revived */
 EXTERN int pending;
 EXTERN int sending;
+EXTERN int verbose;
 
 EXTERN dev_t ROOT_DEV;         /* device number of the root device */
 EXTERN int ROOT_FS_E;           /* kernel endpoint of the root FS proc */
index 4e5791e49c3a6f7daa80758bd6f1085feaa510cf..97883d3f1c9132f97f627d5c21dfba1d861d97d3 100644 (file)
@@ -486,6 +486,7 @@ static int sef_cb_init_fresh(int UNUSED(type), sef_init_info_t *info)
   force_sync = 0;
   receive_from = ANY;
   self = NULL;
+  verbose = 0;
 
   /* Initialize proc endpoints to NONE */
   for (rfp = &fproc[0]; rfp < &fproc[NR_PROCS]; rfp++) {
index e4aaf181c0f07c0a27e90d54884884991be7221a..c394c893e1ddc39f35f85cc7be8407d6932ff86d 100644 (file)
@@ -595,11 +595,81 @@ int ruid;
 int do_svrctl()
 {
   int svrctl;
+  vir_bytes ptr;
 
-  svrctl = m_in.svrctl_req;
+  svrctl = job_m_in.svrctl_req;
+  ptr = (vir_bytes) job_m_in.svrctl_argp;
+  if (((svrctl >> 8) & 0xFF) != 'M') return(EINVAL);
 
   switch (svrctl) {
-  /* No control request implemented yet. */
+    case VFSSETPARAM:
+    case VFSGETPARAM:
+       {
+               struct sysgetenv sysgetenv;
+               char search_key[64];
+               char val[64];
+               int r, s;
+
+               /* Copy sysgetenv structure to VFS */
+               if (sys_datacopy(who_e, ptr, SELF, (vir_bytes) &sysgetenv,
+                                sizeof(sysgetenv)) != OK)
+                       return(EFAULT);
+
+               /* Basic sanity checking */
+               if (svrctl == VFSSETPARAM) {
+                       if (sysgetenv.keylen <= 0 ||
+                           sysgetenv.keylen > (sizeof(search_key) - 1) ||
+                           sysgetenv.vallen <= 0 ||
+                           sysgetenv.vallen >= sizeof(val)) {
+                               return(EINVAL);
+                       }
+               }
+
+               /* Copy parameter "key" */
+               if ((s = sys_datacopy(who_e, (vir_bytes) sysgetenv.key,
+                                     SELF, (vir_bytes) search_key,
+                                     sysgetenv.keylen)) != OK)
+                       return(s);
+               search_key[sysgetenv.keylen] = '\0'; /* Limit string */
+
+               /* Is it a parameter we know? */
+               if (svrctl == VFSSETPARAM) {
+                       if (!strcmp(search_key, "verbose")) {
+                               int verbose_val;
+                               if ((s = sys_datacopy(who_e,
+                                   (vir_bytes) sysgetenv.val, SELF,
+                                   (vir_bytes) &val, sysgetenv.vallen)) != OK)
+                                       return(s);
+                               val[sysgetenv.vallen] = '\0'; /* Limit string */
+                               verbose_val = atoi(val);
+                               if (verbose_val < 0 || verbose_val > 4) {
+                                       return(EINVAL);
+                               }
+                               verbose = verbose_val;
+                               r = OK;
+                       } else {
+                               r = ESRCH;
+                       }
+               } else { /* VFSGETPARAM */
+                       if (!strcmp(search_key, "print_traces")) {
+                               mthread_stacktraces();
+                               sysgetenv.val = 0;
+                               sysgetenv.vallen = 0;
+                               r = OK;
+                       } else {
+                               r = ESRCH;
+                       }
+
+                       if (r == OK) {
+                               if ((s = sys_datacopy(SELF,
+                                   (vir_bytes) &sysgetenv, who_e, ptr,
+                                   sizeof(sysgetenv))) != OK)
+                                       return(s);
+                       }
+               }
+
+               return(r);
+       }
     default:
        return(EINVAL);
   }