} Group;
static unsigned arg_depth = 3;
+static unsigned arg_iterations = 0;
static usec_t arg_delay = 1*USEC_PER_SEC;
static enum {
if (r <= 0)
goto finish;
- p = join(path, "/", fn, NULL);
+ p = strjoin(path, "/", fn, NULL);
free(fn);
if (!p) {
" -m Order by memory load\n"
" -i Order by IO load\n"
" -d --delay=DELAY Specify delay\n"
+ " -n --iterations=N Run for N iterations before exiting\n"
" --depth=DEPTH Maximum traversal depth (default: 2)\n",
program_invocation_short_name);
}
};
static const struct option options[] = {
- { "help", no_argument, NULL, 'h' },
- { "delay", required_argument, NULL, 'd' },
- { "depth", required_argument, NULL, ARG_DEPTH },
- { NULL, 0, NULL, 0 }
+ { "help", no_argument, NULL, 'h' },
+ { "delay", required_argument, NULL, 'd' },
+ { "iterations", required_argument, NULL, 'n' },
+ { "depth", required_argument, NULL, ARG_DEPTH },
+ { NULL, 0, NULL, 0 }
};
int c;
assert(argc >= 1);
assert(argv);
- while ((c = getopt_long(argc, argv, "hptcmid:", options, NULL)) >= 0) {
+ while ((c = getopt_long(argc, argv, "hptcmin:d:", options, NULL)) >= 0) {
switch (c) {
break;
+ case 'n':
+ r = safe_atou(optarg, &arg_iterations);
+ if (r < 0) {
+ log_error("Failed to parse iterations parameter.");
+ return -EINVAL;
+ }
+
+ break;
+
case 'p':
arg_order = ORDER_PATH;
break;
a = hashmap_new(string_hash_func, string_compare_func);
b = hashmap_new(string_hash_func, string_compare_func);
if (!a || !b) {
- log_error("Out of memory");
- r = -ENOMEM;
+ r = log_oom();
goto finish;
}
if (r < 0)
goto finish;
+ if (arg_iterations && iteration >= arg_iterations)
+ break;
+
r = read_one_char(stdin, &key, last_refresh + arg_delay - t, NULL);
if (r == -ETIMEDOUT)
continue;