tgAPIVER,
tgINITPID, tgINITPID_PID,
tgXID, tgUTS, tgSYSINFO,
+ tgFEATURE,
} VserverTag;
static struct {
VserverTag const val;
char const * const descr;
} const TAGS[] = {
- { "CONTEXT", tgCONTEXT, "the current and/or assigned context" },
+ { "CONTEXT", tgCONTEXT, ("the current and/or assigned context; when an optinal argument "
+ "evaluates to false,only the current context will be printed") },
{ "RUNNING", tgRUNNING, "gives out '1' when vserver is running; else, it fails without output" },
{ "VDIR", tgVDIR, "gives out the root-directory of the vserver" },
{ "NAME", tgNAME, "gives out the name of the vserver" },
"context, sysname, nodename, release, version, "
"machine and domainname") },
{ "SYSINFO", tgSYSINFO, "gives out information about the systen" },
+ { "FEATURE", tgFEATURE, "returns 0 iff the queried feature is supported" },
};
int wrapper_exit_code = 1;
if (vc_get_vx_info(xid, &info)==-1) perror("vc_get_vx_info()");
else {
- utilvserver_fmt_long(buf, info.xid);
+ utilvserver_fmt_long(buf, info.initpid);
return buf;
}
if (xid==VC_NOCTX) perror("vc_get_task_xid()");
else if (vc_get_vx_info(xid, &info)==-1) perror("vc_get_vx_info()");
else {
- utilvserver_fmt_long(buf, info.xid);
+ utilvserver_fmt_long(buf, info.initpid);
return buf;
}
}
static char *
-getContext(char *buf, char const *vserver)
+getContext(char *buf, char const *vserver, bool allow_only_static)
{
- xid_t xid = vc_getVserverCtx(vserver, vcCFG_AUTO, true, 0);
+ xid_t xid = vc_getVserverCtx(vserver, vcCFG_AUTO,
+ allow_only_static, 0);
if (xid==VC_NOCTX) return 0;
utilvserver_fmt_long(buf, xid);
}
static int
+testFeature(int argc, char *argv[])
+{
+ return (argc>0 && vc_isSupportedString(argv[0])) ? EXIT_SUCCESS : EXIT_FAILURE;
+}
+
+static bool
+str2bool(char const *str)
+{
+ return atoi(str)!=0 || strchr("yYtY", str[0])!=0;
+}
+
+static int
execQuery(char const *vserver, VserverTag tag, int argc, char *argv[])
{
char const * res = 0;
res = (vc_getVserverCtx(vserver, vcCFG_AUTO, false, 0)==VC_NOCTX) ? 0 : "1";
break;
- case tgCONTEXT : res = getContext(buf, vserver); break;
+ case tgCONTEXT : res = getContext(buf, vserver,
+ argc==0 || str2bool(argv[0])); break;
case tgXID : res = getXid(buf, vserver); break;
case tgINITPID : res = getInitPid(buf, xid); break;
case tgINITPID_PID : res = getInitPidPid(buf, vserver); break;
case tgAPIVER : res = getAPIVer(buf); break;
case tgUTS : res = getUTS(buf, xid, argc, argv); break;
case tgSYSINFO : return printSysInfo(buf); break;
+ case tgFEATURE : return testFeature(argc,argv); break;
default : assert(false); abort(); // TODO
}