X-Git-Url: http://git.linux-vserver.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fvtag.c;h=9c43c8ba42b5afde71b9324aa8728c83fc55a217;hb=148ab3024621f97b9cf95091657db2448098bc66;hp=3aa6cc4a94866f086ae17d2fea601ed208152930;hpb=3564d8678a2134185e5e6e83083de027b359ca28;p=util-vserver.git diff --git a/src/vtag.c b/src/vtag.c index 3aa6cc4..9c43c8b 100644 --- a/src/vtag.c +++ b/src/vtag.c @@ -38,6 +38,7 @@ #define CMD_CREATE 0x4001 #define CMD_MIGRATE 0x4002 #define CMD_SILENTEXIST 0x4003 +#define CMD_SILENT 0x4004 struct option const @@ -47,6 +48,7 @@ CMDLINE_OPTIONS[] = { { "tag", required_argument, 0, CMD_TAG }, { "create", no_argument, 0, CMD_CREATE }, { "migrate", no_argument, 0, CMD_MIGRATE }, + { "silent", no_argument, 0, CMD_SILENT }, { "silentexist", no_argument, 0, CMD_SILENTEXIST }, { 0,0,0,0 }, }; @@ -72,6 +74,8 @@ showHelp(int fd, char const *cmd, int res) " can be:\n" " --silentexist ... be silent when context exists already; useful\n" " for '--create' only\n" + " --silent ... if the feature is not supported, just execute\n" + " \n" "\n" "'vtag --create' exits with code 254 iff the context exists already.\n" "\n" @@ -96,8 +100,25 @@ doit(struct Arguments const *args, char *argv[]) { tag_t tag; - if (!vc_isSupported(vcFEATURE_PPTAG)) - goto exec; + if (!vc_isSupported(vcFEATURE_PPTAG)) { + if (args->verbosity >= 1) { + errno = ENOSYS; + perror(ENSC_WRAPPERS_PREFIX); + return wrapper_exit_code; + } + else + goto exec; + } + if (args->tag == VC_DYNAMIC_XID) { + if (args->verbosity >= 1) { + WRITE_MSG(2, "You must specify the tag with '--tag'; try '--help' for more information\n"); + return wrapper_exit_code; + } + else { + WRITE_MSG(2, ENSC_WRAPPERS_PREFIX "WARNING: A dynamic tag has been specified, this is not supported\n"); + goto exec; + } + } if (args->do_create) { tag = vc_tag_create(args->tag); @@ -129,7 +150,7 @@ exec: int main (int argc, char *argv[]) { struct Arguments args = { - .tag = VC_NOCTX, + .tag = VC_DYNAMIC_XID, .do_create = false, .do_migrate = false, .is_silentexist = false, @@ -139,7 +160,7 @@ int main (int argc, char *argv[]) while (1) { int c = getopt_long(argc, argv, "+", CMDLINE_OPTIONS, 0); if (c==-1) break; - + switch (c) { case CMD_HELP : showHelp(1, argv[0], 0); case CMD_VERSION : showVersion(); @@ -147,6 +168,7 @@ int main (int argc, char *argv[]) case CMD_MIGRATE : args.do_migrate = true; break; case CMD_SILENTEXIST : args.is_silentexist = true; break; case CMD_TAG : args.tag = Evc_tagopt2tag(optarg,true); break; + case CMD_SILENT : args.verbosity--; break; default : WRITE_MSG(2, "Try '"); @@ -161,8 +183,6 @@ int main (int argc, char *argv[]) WRITE_MSG(2, "Neither '--create' nor '--migrate' specified; try '--help' for more information\n"); else if (args.do_create && args.do_migrate) WRITE_MSG(2, "Can not specify '--create' and '--migrate' at the same time; try '--help' for more information\n"); - else if (args.tag==VC_NOCTX) - WRITE_MSG(2, "You must specify the tag with '--tag'; try '--help' for more information\n"); else if (optind>=argc) WRITE_MSG(2, "No command given; use '--help' for more information.\n"); else