From: Enrico Scholz Date: Tue, 13 Jan 2004 14:15:53 +0000 (+0000) Subject: minor/medium cleanups X-Git-Tag: VERSION_0_10~965 X-Git-Url: http://git.linux-vserver.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=19f003f66c0d83ae8ade956fd2b357a109fc73e0;p=util-vserver.git minor/medium cleanups git-svn-id: http://svn.linux-vserver.org/svn/util-vserver/trunk@562 94cd875c-1c1d-0410-91d2-eb244daf1a30 --- diff --git a/util-vserver/src/chxid.c b/util-vserver/src/chxid.c index e2b6fa8..1af6c53 100644 --- a/util-vserver/src/chxid.c +++ b/util-vserver/src/chxid.c @@ -103,15 +103,17 @@ handleFile(char const *name, char const * display_name, } void -checkParams(struct Arguments const UNUSED *args, int argc) +fixupParams(struct Arguments UNUSED *args, int argc) { if (optind==argc) { WRITE_MSG(2, "No filename given; use '--help' for more information\n"); exit(1); } - if (args->ctx==VC_NOCTX) { - WRITE_MSG(2, "No valid context given; use '--help' for more information\n"); + if (args->ctx_str==0) { + WRITE_MSG(2, "No context given; use '--help' for more information\n"); exit(1); } + + args->ctx = resolveCtx(args->ctx_str); } diff --git a/util-vserver/src/fstool.c b/util-vserver/src/fstool.c index 780997f..006d3aa 100644 --- a/util-vserver/src/fstool.c +++ b/util-vserver/src/fstool.c @@ -161,30 +161,6 @@ processFile(char const *path) return handleFile(path, path, &st); } -static xid_t -resolveCtx(char const *str) -{ - xid_t res; - - if (*str==':') ++str; - else { - char *end_ptr; - long result = strtol(str, &end_ptr, 0); - - if (end_ptr>str && *end_ptr==0) return result; - } - - res = vc_getVserverCtx(str, vcCFG_AUTO, true, 0); - if (res==VC_NOCTX) { - WRITE_MSG(2, "Can not find a vserver with name '"); - WRITE_STR(2, str); - WRITE_MSG(2, "', or vserver does not have a static context\n"); - exit(1); - } - - return res; -} - int main(int argc, char *argv[]) { uint64_t err_cnt = 0; @@ -220,7 +196,7 @@ int main(int argc, char *argv[]) case 'n' : args.do_mapping = false; break; case 's' : args.do_set = true; break; case 'u' : args.do_unset = true; break; - case 'c' : args.ctx = resolveCtx(optarg); break; + case 'c' : args.ctx_str = optarg; break; default : WRITE_MSG(2, "Try '"); WRITE_STR(2, argv[0]); @@ -230,7 +206,7 @@ int main(int argc, char *argv[]) } } - checkParams(&args, argc); + fixupParams(&args, argc); if (optind==argc) err_cnt = processFile("."); diff --git a/util-vserver/src/fstool.h b/util-vserver/src/fstool.h index 73a7f21..8bc396a 100644 --- a/util-vserver/src/fstool.h +++ b/util-vserver/src/fstool.h @@ -31,16 +31,17 @@ struct stat; struct Arguments { - bool do_recurse; - bool do_display_dot; - bool do_display_dir; - bool do_mapping; - bool immutable; - bool immulink; - xid_t ctx; - bool is_legacy; - bool do_set; - bool do_unset; + bool do_recurse; + bool do_display_dot; + bool do_display_dir; + bool do_mapping; + bool immutable; + bool immulink; + char const * ctx_str; + xid_t ctx; + bool is_legacy; + bool do_set; + bool do_unset; }; extern struct option const CMDLINE_OPTIONS[]; @@ -48,9 +49,10 @@ extern char const CMDLINE_OPTIONS_SHORT[]; extern struct Arguments const * global_args; bool checkForRace(int fd, char const * name, struct stat const *exp_st); -void checkParams(struct Arguments const *, int argc); +void fixupParams(struct Arguments *, int argc); bool handleFile(char const *d_name, char const *full_name, struct stat const *); void showHelp(int fd, char const *cmd, int res); void showVersion(); +xid_t resolveCtx(char const *str); #endif // H_UTIL_VSERVER_SRC_FSTOOL_H diff --git a/util-vserver/src/lsxid.c b/util-vserver/src/lsxid.c index d6bd531..cc7cd18 100644 --- a/util-vserver/src/lsxid.c +++ b/util-vserver/src/lsxid.c @@ -72,7 +72,7 @@ showVersion() } void -checkParams(struct Arguments const UNUSED * args, int UNUSED argc) +fixupParams(struct Arguments UNUSED * args, int UNUSED argc) { } diff --git a/util-vserver/src/setattr.c b/util-vserver/src/setattr.c index 4d4ba91..74de450 100644 --- a/util-vserver/src/setattr.c +++ b/util-vserver/src/setattr.c @@ -75,7 +75,7 @@ showVersion() } void -checkParams(struct Arguments const * args, int argc) +fixupParams(struct Arguments * args, int argc) { if (optind==argc) { WRITE_MSG(2, "No filename given; use '--help' for more information\n"); diff --git a/util-vserver/src/showattr.c b/util-vserver/src/showattr.c index 01a9f52..cf68304 100644 --- a/util-vserver/src/showattr.c +++ b/util-vserver/src/showattr.c @@ -73,7 +73,7 @@ showVersion() } void -checkParams(struct Arguments const UNUSED * args, int UNUSED argc) +fixupParams(struct Arguments UNUSED * args, int UNUSED argc) { }