From: Ben Gras Date: Fri, 22 Jul 2005 18:29:58 +0000 (+0000) Subject: . Junk-filling gap+stack code on exec() if enabled (not enabled now) X-Git-Tag: v3.1.0~567 X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/man.dnssec-keygen.html?a=commitdiff_plain;h=ca80161f4074a6b76eebbb05d78b71b82dc51fce;p=minix.git . Junk-filling gap+stack code on exec() if enabled (not enabled now) . Allow 'boot monitor' variable changes and additions by svrctl call --- diff --git a/servers/pm/exec.c b/servers/pm/exec.c index 39021e82b..d9e6941d0 100644 --- a/servers/pm/exec.c +++ b/servers/pm/exec.c @@ -378,6 +378,21 @@ phys_bytes tot_bytes; /* total memory to allocate, including gap */ panic(__FILE__,"new_mem can't zero", s); } +#define ENABLE_USAGE_TEST 0 +#if ENABLE_USAGE_TEST + /* Junk-fill gap and stack. + * Mind the gap.. + */ + { + static int pat = 1; + if ((s=sys_memset(pat++ & 0xff, + (rmp->mp_seg[D].mem_phys + rmp->mp_seg[D].mem_len) << CLICK_SHIFT, + (gap_clicks + stack_clicks) << CLICK_SHIFT)) != OK) { + panic(__FILE__,"can't junk-fill", s); + } + } +#endif + #if DEAD_CODE while (bytes > 0) { static char zero[1024]; /* used to zero bss */ diff --git a/servers/pm/misc.c b/servers/pm/misc.c index 636bd8150..f71c7e7d6 100644 --- a/servers/pm/misc.c +++ b/servers/pm/misc.c @@ -217,6 +217,13 @@ PUBLIC int do_svrctl() { int s, req; vir_bytes ptr; +#define MAX_LOCAL_PARAMS 2 + static struct { + char name[30]; + char value[30]; + } local_param_overrides[MAX_LOCAL_PARAMS]; + static int local_params = 0; + req = m_in.svrctl_req; ptr = (vir_bytes) m_in.svrctl_argp; @@ -236,6 +243,7 @@ PUBLIC int do_svrctl() /* Control operations local to the PM. */ switch(req) { + case MMSETPARAM: case MMGETPARAM: { struct sysgetenv sysgetenv; char search_key[64]; @@ -247,20 +255,52 @@ PUBLIC int do_svrctl() if (sys_datacopy(who, ptr, SELF, (vir_bytes) &sysgetenv, sizeof(sysgetenv)) != OK) return(EFAULT); + /* Set a param override? */ + if(req == MMSETPARAM) { + if(local_params >= MAX_LOCAL_PARAMS) return ENOSPC; + if(sysgetenv.keylen <= 0 || sysgetenv.keylen >= sizeof(local_param_overrides[local_params].name) + || sysgetenv.vallen <= 0 || sysgetenv.vallen >= sizeof(local_param_overrides[local_params].value)) + return EINVAL; + + if ((s = sys_datacopy(who, (vir_bytes) sysgetenv.key, + SELF, (vir_bytes) local_param_overrides[local_params].name, + sysgetenv.keylen)) != OK) + return s; + if ((s = sys_datacopy(who, (vir_bytes) sysgetenv.val, + SELF, (vir_bytes) local_param_overrides[local_params].value, + sysgetenv.keylen)) != OK) + return s; + local_param_overrides[local_params].name[sysgetenv.keylen] = '\0'; + local_param_overrides[local_params].value[sysgetenv.vallen] = '\0'; + + local_params++; + + return OK; + } + if (sysgetenv.keylen == 0) { /* copy all parameters */ val_start = monitor_params; val_len = sizeof(monitor_params); } else { /* lookup value for key */ + int p; /* Try to get a copy of the requested key. */ if (sysgetenv.keylen > sizeof(search_key)) return(EINVAL); if ((s = sys_datacopy(who, (vir_bytes) sysgetenv.key, SELF, (vir_bytes) search_key, sysgetenv.keylen)) != OK) return(s); - /* Make sure key is null-terminated and lookup value. */ + /* Make sure key is null-terminated and lookup value. + * First check local overrides. + */ search_key[sysgetenv.keylen-1]= '\0'; - if ((val_start = find_param(search_key)) == NULL) + for(p = 0; p < local_params; p++) { + if(!strcmp(search_key, local_param_overrides[p].name)) { + val_start = local_param_overrides[p].value; + break; + } + } + if(p >= local_params && (val_start = find_param(search_key)) == NULL) return(ESRCH); val_len = strlen(val_start) + 1; }