From: Enrico Scholz Date: Wed, 24 Mar 2004 05:30:49 +0000 (+0000) Subject: enhanced the in-chain operation; make it a noop when called without opts X-Git-Tag: VERSION_0_10~221 X-Git-Url: http://git.linux-vserver.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8d3d8da7de6e56f5fd414a240ac755db0d49b93b;p=util-vserver.git enhanced the in-chain operation; make it a noop when called without opts enhanced error messages git-svn-id: http://svn.linux-vserver.org/svn/util-vserver/trunk@1354 94cd875c-1c1d-0410-91d2-eb244daf1a30 --- diff --git a/util-vserver/src/vsched.c b/util-vserver/src/vsched.c index c6e945b..3ccc9aa 100644 --- a/util-vserver/src/vsched.c +++ b/util-vserver/src/vsched.c @@ -90,6 +90,7 @@ int main(int argc, char *argv[]) { xid_t xid = VC_NOCTX; struct vc_set_sched sched = { 0,0,0,0,0,0 }; + bool do_it = false; while (1) { int c = getopt_long(argc, argv, "+", CMDLINE_OPTIONS, 0); @@ -98,13 +99,13 @@ int main(int argc, char *argv[]) switch (c) { case CMD_HELP : showHelp(1, argv[0], 0); case CMD_VERSION : showVersion(); - case CMD_XID : xid = Evc_xidopt2xid(optarg,true); break; - case CMD_FRATE : sched.fill_rate = atoi(optarg); break; - case CMD_INTERVAL : sched.interval = atoi(optarg); break; - case CMD_TOKENS : sched.tokens = atoi(optarg); break; - case CMD_TOK_MIN : sched.tokens_min = atoi(optarg); break; - case CMD_TOK_MAX : sched.tokens_max = atoi(optarg); break; - case CMD_CPU_MASK : sched.cpu_mask = atoi(optarg); break; + case CMD_XID : xid = Evc_xidopt2xid(optarg,true); break; + case CMD_FRATE : sched.fill_rate = atoi(optarg); do_it = true; break; + case CMD_INTERVAL : sched.interval = atoi(optarg); do_it = true; break; + case CMD_TOKENS : sched.tokens = atoi(optarg); do_it = true; break; + case CMD_TOK_MIN : sched.tokens_min = atoi(optarg); do_it = true; break; + case CMD_TOK_MAX : sched.tokens_max = atoi(optarg); do_it = true; break; + case CMD_CPU_MASK : sched.cpu_mask = atoi(optarg); do_it = true; break; default : WRITE_MSG(2, "Try '"); WRITE_STR(2, argv[0]); @@ -115,14 +116,19 @@ int main(int argc, char *argv[]) } if (xid==VC_NOCTX && optind==argc) { - WRITE_MSG(2, "Neither '--xid' nor a program was specified; try '--help' for more information\n"); - exit(255); + WRITE_MSG(2, "Without a program, '--xid' must be used; try '--help' for more information\n"); + exit(wrapper_exit_code); + } + + if (!do_it && optind==argc) { + WRITE_MSG(2, "Neither an option nor a program was specified; try '--help' for more information\n"); + exit(wrapper_exit_code); } if (xid==VC_NOCTX) xid = Evc_get_task_xid(0); - if (vc_set_sched(xid, &sched)==-1) { + if (do_it && vc_set_sched(xid, &sched)==-1) { perror("vc_set_sched()"); exit(255); }