}
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);
}
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;
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]);
}
}
- checkParams(&args, argc);
+ fixupParams(&args, argc);
if (optind==argc)
err_cnt = processFile(".");
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[];
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
}
void
-checkParams(struct Arguments const UNUSED * args, int UNUSED argc)
+fixupParams(struct Arguments UNUSED * args, int UNUSED argc)
{
}
}
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");
}
void
-checkParams(struct Arguments const UNUSED * args, int UNUSED argc)
+fixupParams(struct Arguments UNUSED * args, int UNUSED argc)
{
}