]> Zhao Yanbai Git Server - minix.git/commitdiff
. Junk-filling gap+stack code on exec() if enabled (not enabled now)
authorBen Gras <ben@minix3.org>
Fri, 22 Jul 2005 18:29:58 +0000 (18:29 +0000)
committerBen Gras <ben@minix3.org>
Fri, 22 Jul 2005 18:29:58 +0000 (18:29 +0000)
. Allow 'boot monitor' variable changes and additions by svrctl call

servers/pm/exec.c
servers/pm/misc.c

index 39021e82b97c4700945925600b6201dc8a947b1c..d9e6941d03ce8bb87992a939a65f9e3646180b89 100644 (file)
@@ -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 */
index 636bd815064972e53751192c98031de2c78832eb..f71c7e7d6eadeb84079bc2ba2c74f54f76b4f164 100644 (file)
@@ -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;
       }