small cosmetical fix
authorEnrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
Mon, 5 Jan 2004 21:53:33 +0000 (21:53 +0000)
committerEnrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
Mon, 5 Jan 2004 21:53:33 +0000 (21:53 +0000)
git-svn-id: http://svn.linux-vserver.org/svn/util-vserver/trunk@537 94cd875c-1c1d-0410-91d2-eb244daf1a30

util-vserver/lib/fmtx.hc
util-vserver/lib/getvserverbyctx.c
util-vserver/lib/getvserverctx.c
util-vserver/lib/vserver-internal.h
util-vserver/lib/vserver.h

index df29616..4f25ae6 100644 (file)
@@ -32,7 +32,7 @@ CONCAT(FMT_P(xuint),)(char *ptr, CONCAT(uint_least,_t) val)
 
 size_t
 CONCAT(FMT_P(xint),)(char *ptr,
-                   CONCAT(int_least,_t) val)
+                    CONCAT(int_least,_t) val)
 {
   size_t       offset=0;
   if (val<0) {
index 5759f1c..ce45d43 100644 (file)
@@ -55,7 +55,7 @@ vc_getVserverByCtx(xid_t ctx, vcCfgStyle *style, char const *revdir)
     case vcCFG_RECENT_SHORT    :
     case vcCFG_RECENT_FULL     :
        // check if expected ctx == actual ctx
-      if (vc_getVserverCtx(path, vcCFG_RECENT_FULL)!=ctx) return 0;
+      if (vc_getVserverCtx(path, vcCFG_RECENT_FULL, false, 0)!=ctx) return 0;
 
       if (style) *style = vcCFG_RECENT_FULL;
       return strdup(path);
index 774c80f..71de198 100644 (file)
@@ -61,30 +61,41 @@ getCtxFromFile(char const *pathname)
 }
 
 xid_t
-vc_getVserverCtx(char const *id, vcCfgStyle style)
+vc_getVserverCtx(char const *id, vcCfgStyle style, bool honor_static, bool *is_running)
 {
   size_t               l1 = strlen(id);
   char                 buf[sizeof(CONFDIR "//") + l1 + sizeof("/run")];
                            
   if (style==vcCFG_NONE || style==vcCFG_AUTO)
     style = vc_getVserverCfgStyle(id);
-  
+
+  if (is_running) *is_running = false;
+
   switch (style) {
     case vcCFG_NONE            :  return VC_NOCTX;
     case vcCFG_LEGACY          :  return VC_NOCTX;     // todo
     case vcCFG_RECENT_SHORT    :
     case vcCFG_RECENT_FULL     : {
       size_t           idx = 0;
+      xid_t            res = 0;
+
       if (style==vcCFG_RECENT_SHORT) {
        memcpy(buf, CONFDIR "/", sizeof(CONFDIR "/")-1);
        idx  = sizeof(CONFDIR "/") - 1;
       }
       memcpy(buf+idx, id, l1);    idx += l1;
-      memcpy(buf+idx, "/run", 4); idx += 4;
-      buf[idx] = '\0';
+      memcpy(buf+idx, "/run", 5);      // appends '\0' too
       
+      res = getCtxFromFile(buf);
+      if (is_running) *is_running = res!=VC_NOCTX;
+      
+      if (res==VC_NOCTX && honor_static) {
+       memcpy(buf+idx, "/context", 9); // appends '\0' too
 
-      return getCtxFromFile(buf);
+       res = getCtxFromFile(buf);
+      }
+      
+      return res;
     }
     default                    :  return VC_NOCTX;
   }
index 601f687..9c051b2 100644 (file)
@@ -42,7 +42,7 @@
 #  define VC_SELECT(ID)        case ID: if(1)
 #  define CALL_VC(...)                                 \
   switch (utilvserver_checkCompatVersion()&~0xff) {    \
-    case -1    :  if (1) break;                        \
+    case -1 & ~0xff    :  if (1) break;                \
       VC_SUFFIX, __VA_ARGS__ , VC_PREFIX;              \
     default    :  errno = EINVAL;                      \
   }                                                    \
index d45dc9d..f0439b0 100644 (file)
@@ -22,6 +22,7 @@
 
 #include <stdint.h>
 #include <stdlib.h>
+#include <stdbool.h>
 #include <sys/types.h>
 
 /** the value which is returned in error-case (no ctx found) */
@@ -175,9 +176,15 @@ extern "C" {
 
   char *       vc_getVserverVdir(char const *id, vcCfgStyle style);
 
-  /** Returns the ctx of the given vserver, or VC_NOCTX if vserver is not
-   *  running */
-  xid_t                vc_getVserverCtx(char const *id, vcCfgStyle style);
+  /** Returns the ctx of the given vserver. When vserver is not running and
+   *  'honor_static' is false, VC_NOCTX will be returned. Else, when
+   *  'honor_static' is true and a static assignment exists, those value will
+   *  be returned. Else, the result will be VC_NOCTX.
+   *
+   *  When 'is_running' is not null, the status of the vserver will be
+   *  assigned to this variable. */
+  xid_t                vc_getVserverCtx(char const *id, vcCfgStyle style,
+                                bool honor_static, bool /*@null@*/ *is_running);
 
   /** Resolves the cfg-path of the vserver owning the given ctx. 'revdir' will
       be used as the directory holding the mapping-links; when NULL, the