From: Daniel Hokka Zakrisson Date: Sat, 25 Aug 2007 16:56:12 +0000 (+0000) Subject: Fallback to context if ncontext/tag don't exist. X-Git-Tag: release-0.30.214~9 X-Git-Url: http://git.linux-vserver.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=de62ee14e1d5f0b672843ae45972d0baf4e375aa;p=util-vserver.git Fallback to context if ncontext/tag don't exist. Fix remanining vc_getVserverCtx caller. git-svn-id: http://svn.linux-vserver.org/svn/util-vserver/trunk@2596 94cd875c-1c1d-0410-91d2-eb244daf1a30 --- diff --git a/lib/getvserverbyctx-compat.hc b/lib/getvserverbyctx-compat.hc index 3e7fde2..bb4c578 100644 --- a/lib/getvserverbyctx-compat.hc +++ b/lib/getvserverbyctx-compat.hc @@ -48,7 +48,7 @@ handleLegacy(xid_t xid) if (l<=4 || strcmp(name+l-4, ".ctx")!=0) continue; name[l-4] = '\0'; - cur_xid = vc_getVserverCtx(name, vcCFG_LEGACY, false, 0); + cur_xid = vc_getVserverCtx(name, vcCFG_LEGACY, false, 0, vcCTX_XID); if (cur_xid!=xid) continue; result = strdup(name); diff --git a/lib/getvserverctx.c b/lib/getvserverctx.c index fda8d73..42b940c 100644 --- a/lib/getvserverctx.c +++ b/lib/getvserverctx.c @@ -175,12 +175,15 @@ vc_getVserverCtx(char const *id, vcCfgStyle style, bool honor_static, bool *is_r : VC_NOCTX); // correct the value of 'res' free(cur_name); + + if (is_running) // fill 'is_running' information... + *is_running = res!=VC_NOCTX; } - - if (is_running) // fill 'is_running' information... - *is_running = res!=VC_NOCTX; - + else if (is_running) + *is_running = false; + if (res==VC_NOCTX && honor_static) { +check_static: switch (type) { case vcCTX_XID: memcpy(buf+idx, "/context", 9); // appends '\0' too @@ -194,6 +197,10 @@ vc_getVserverCtx(char const *id, vcCfgStyle style, bool honor_static, bool *is_r } res = getCtxFromFile(buf); + if (res==VC_NOCTX && type!=vcCTX_XID) { + type = vcCTX_XID; + goto check_static; + } } return res;