From: Thomas Veerman Date: Fri, 30 Mar 2012 09:24:44 +0000 (+0000) Subject: VFS: enable sending control messages X-Git-Tag: v3.2.1~601 X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/index.html?a=commitdiff_plain;h=0d63d9e125f291bca8676d2bf6e06f93549e29eb;p=minix.git VFS: enable sending control messages --- diff --git a/common/include/sys/svrctl.h b/common/include/sys/svrctl.h index 2d1f69bdf..1bdad0e33 100644 --- a/common/include/sys/svrctl.h +++ b/common/include/sys/svrctl.h @@ -18,6 +18,10 @@ Created: Feb 15, 1994 by Philip Homburg #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. */ diff --git a/servers/vfs/glo.h b/servers/vfs/glo.h index e2603ae62..ac35c6d94 100644 --- a/servers/vfs/glo.h +++ b/servers/vfs/glo.h @@ -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 */ diff --git a/servers/vfs/main.c b/servers/vfs/main.c index 4e5791e49..97883d3f1 100644 --- a/servers/vfs/main.c +++ b/servers/vfs/main.c @@ -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++) { diff --git a/servers/vfs/misc.c b/servers/vfs/misc.c index e4aaf181c..c394c893e 100644 --- a/servers/vfs/misc.c +++ b/servers/vfs/misc.c @@ -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); }