diff options
-rw-r--r-- | bftw.c | 20 | ||||
-rw-r--r-- | bftw.h | 10 | ||||
-rw-r--r-- | eval.c | 12 | ||||
-rw-r--r-- | parse.c | 30 |
4 files changed, 36 insertions, 36 deletions
@@ -943,7 +943,7 @@ static bool bftw_need_stat(const struct bftw_state *state) { } if (ftwbuf->type == BFTW_DIR) { - if (state->flags & (BFTW_DETECT_CYCLES | BFTW_MOUNT | BFTW_XDEV)) { + if (state->flags & (BFTW_DETECT_CYCLES | BFTW_SKIP_MOUNTS | BFTW_PRUNE_MOUNTS)) { return true; } #if __linux__ @@ -1048,9 +1048,9 @@ static void bftw_init_ftwbuf(struct bftw_state *state, enum bftw_visit visit) { return; } - int follow_flags = BFTW_LOGICAL; + int follow_flags = BFTW_FOLLOW_ALL; if (ftwbuf->depth == 0) { - follow_flags |= BFTW_COMFOLLOW; + follow_flags |= BFTW_FOLLOW_ROOTS; } bool follow = state->flags & follow_flags; if (follow) { @@ -1127,7 +1127,7 @@ static enum bftw_action bftw_visit(struct bftw_state *state, const char *name, e return BFTW_STOP; } - if ((state->flags & BFTW_MOUNT) && bftw_is_mount(state, name)) { + if ((state->flags & BFTW_SKIP_MOUNTS) && bftw_is_mount(state, name)) { return BFTW_PRUNE; } @@ -1148,7 +1148,7 @@ static enum bftw_action bftw_visit(struct bftw_state *state, const char *name, e goto done; } - if ((state->flags & BFTW_XDEV) && bftw_is_mount(state, name)) { + if ((state->flags & BFTW_PRUNE_MOUNTS) && bftw_is_mount(state, name)) { ret = BFTW_PRUNE; goto done; } @@ -1288,7 +1288,7 @@ static enum bftw_action bftw_release_reader(struct bftw_state *state, enum bftw_ static enum bftw_action bftw_release_file(struct bftw_state *state, enum bftw_release_flags flags) { enum bftw_action ret = BFTW_CONTINUE; - if (!(state->flags & BFTW_DEPTH)) { + if (!(state->flags & BFTW_POST_ORDER)) { flags = 0; } bool visit = flags & BFTW_VISIT_FILE; @@ -1588,7 +1588,7 @@ static void bftw_ids_init(const struct bftw_args *args, struct bftw_ids_state *s *ids_args = *args; ids_args->callback = bftw_ids_callback; ids_args->ptr = state; - ids_args->flags &= ~BFTW_DEPTH; + ids_args->flags &= ~BFTW_POST_ORDER; ids_args->strategy = BFTW_DFS; } @@ -1628,7 +1628,7 @@ static int bftw_ids(const struct bftw_args *args) { ++state.max_depth; } - if (args->flags & BFTW_DEPTH) { + if (args->flags & BFTW_POST_ORDER) { state.visit = BFTW_POST; state.force_visit = true; @@ -1666,10 +1666,10 @@ static int bftw_eds(const struct bftw_args *args) { state.max_depth *= 2; } - if (!state.quit && (args->flags & BFTW_DEPTH)) { + if (!state.quit && (args->flags & BFTW_POST_ORDER)) { state.visit = BFTW_POST; state.min_depth = 0; - ids_args.flags |= BFTW_DEPTH; + ids_args.flags |= BFTW_POST_ORDER; if (bftw_auto(&ids_args) != 0) { state.error = errno; @@ -177,17 +177,17 @@ enum bftw_flags { /** Attempt to recover from encountered errors. */ BFTW_RECOVER = 1 << 1, /** Visit directories in post-order as well as pre-order. */ - BFTW_DEPTH = 1 << 2, + BFTW_POST_ORDER = 1 << 2, /** If the initial path is a symbolic link, follow it. */ - BFTW_COMFOLLOW = 1 << 3, + BFTW_FOLLOW_ROOTS = 1 << 3, /** Follow all symbolic links. */ - BFTW_LOGICAL = 1 << 4, + BFTW_FOLLOW_ALL = 1 << 4, /** Detect directory cycles. */ BFTW_DETECT_CYCLES = 1 << 5, /** Skip mount points and their descendents. */ - BFTW_MOUNT = 1 << 6, + BFTW_SKIP_MOUNTS = 1 << 6, /** Skip the descendents of mount points. */ - BFTW_XDEV = 1 << 7, + BFTW_PRUNE_MOUNTS = 1 << 7, /** Sort directory entries before processing them. */ BFTW_SORT = 1 << 8, }; @@ -1197,7 +1197,7 @@ static enum bftw_action cmdline_callback(const struct BFTW *ftwbuf, void *ptr) { // In -depth mode, only handle directories on the BFTW_POST visit enum bftw_visit expected_visit = BFTW_PRE; - if ((cmdline->flags & BFTW_DEPTH) + if ((cmdline->flags & BFTW_POST_ORDER) && (cmdline->strategy == BFTW_IDS || ftwbuf->type == BFTW_DIR) && ftwbuf->depth < cmdline->maxdepth) { expected_visit = BFTW_POST; @@ -1278,12 +1278,12 @@ static void dump_bftw_flags(enum bftw_flags flags) { DEBUG_FLAG(flags, 0); DEBUG_FLAG(flags, BFTW_STAT); DEBUG_FLAG(flags, BFTW_RECOVER); - DEBUG_FLAG(flags, BFTW_DEPTH); - DEBUG_FLAG(flags, BFTW_COMFOLLOW); - DEBUG_FLAG(flags, BFTW_LOGICAL); + DEBUG_FLAG(flags, BFTW_POST_ORDER); + DEBUG_FLAG(flags, BFTW_FOLLOW_ROOTS); + DEBUG_FLAG(flags, BFTW_FOLLOW_ALL); DEBUG_FLAG(flags, BFTW_DETECT_CYCLES); - DEBUG_FLAG(flags, BFTW_MOUNT); - DEBUG_FLAG(flags, BFTW_XDEV); + DEBUG_FLAG(flags, BFTW_SKIP_MOUNTS); + DEBUG_FLAG(flags, BFTW_PRUNE_MOUNTS); DEBUG_FLAG(flags, BFTW_SORT); assert(!flags); @@ -441,7 +441,7 @@ out: static int stat_arg(const struct parser_state *state, struct expr *expr, struct bfs_stat *sb) { const struct cmdline *cmdline = state->cmdline; - bool follow = cmdline->flags & (BFTW_COMFOLLOW | BFTW_LOGICAL); + bool follow = cmdline->flags & (BFTW_FOLLOW_ROOTS | BFTW_FOLLOW_ALL); enum bfs_stat_flag flags = follow ? BFS_STAT_TRYFOLLOW : BFS_STAT_NOFOLLOW; int ret = bfs_stat(AT_FDCWD, expr->sdata, flags, sb); @@ -939,7 +939,7 @@ static struct expr *parse_optlevel(struct parser_state *state, int arg1, int arg */ static struct expr *parse_follow(struct parser_state *state, int flags, int option) { struct cmdline *cmdline = state->cmdline; - cmdline->flags &= ~(BFTW_COMFOLLOW | BFTW_LOGICAL); + cmdline->flags &= ~(BFTW_FOLLOW_ROOTS | BFTW_FOLLOW_ALL); cmdline->flags |= flags; if (option) { return parse_nullary_positional_option(state); @@ -1116,7 +1116,7 @@ static struct expr *parse_daystart(struct parser_state *state, int arg1, int arg * Parse -delete. */ static struct expr *parse_delete(struct parser_state *state, int arg1, int arg2) { - state->cmdline->flags |= BFTW_DEPTH; + state->cmdline->flags |= BFTW_POST_ORDER; state->depth_arg = state->argv[0]; return parse_nullary_action(state, eval_delete); } @@ -1125,7 +1125,7 @@ static struct expr *parse_delete(struct parser_state *state, int arg1, int arg2) * Parse -d. */ static struct expr *parse_depth(struct parser_state *state, int arg1, int arg2) { - state->cmdline->flags |= BFTW_DEPTH; + state->cmdline->flags |= BFTW_POST_ORDER; state->depth_arg = state->argv[0]; return parse_nullary_flag(state); } @@ -1540,7 +1540,7 @@ static struct expr *parse_mount(struct parser_state *state, int arg1, int arg2) "${blu}-xdev${rs}, due to http://austingroupbugs.net/view.php?id=1133.\n\n", state->argv[0]); - state->cmdline->flags |= BFTW_XDEV; + state->cmdline->flags |= BFTW_PRUNE_MOUNTS; state->mount_arg = state->argv[0]; return parse_nullary_option(state); } @@ -2508,7 +2508,7 @@ static struct expr *parse_xattr(struct parser_state *state, int arg1, int arg2) * Parse -xdev. */ static struct expr *parse_xdev(struct parser_state *state, int arg1, int arg2) { - state->cmdline->flags |= BFTW_XDEV; + state->cmdline->flags |= BFTW_PRUNE_MOUNTS; state->xdev_arg = state->argv[0]; return parse_nullary_option(state); } @@ -2915,8 +2915,8 @@ static const struct table_entry parse_table[] = { {"-Btime", T_TEST, parse_time, BFS_STAT_BTIME, DAYS}, {"-D", T_FLAG, parse_debug}, {"-E", T_FLAG, parse_regex_extended}, - {"-H", T_FLAG, parse_follow, BFTW_COMFOLLOW, false}, - {"-L", T_FLAG, parse_follow, BFTW_LOGICAL, false}, + {"-H", T_FLAG, parse_follow, BFTW_FOLLOW_ROOTS, false}, + {"-L", T_FLAG, parse_follow, BFTW_FOLLOW_ALL, false}, {"-O", T_FLAG, parse_optlevel, 0, 0, true}, {"-P", T_FLAG, parse_follow, 0, false}, {"-S", T_FLAG, parse_search_strategy}, @@ -2947,7 +2947,7 @@ static const struct table_entry parse_table[] = { {"-f", T_FLAG, parse_f}, {"-false", T_TEST, parse_const, false}, {"-fls", T_ACTION, parse_fls}, - {"-follow", T_OPTION, parse_follow, BFTW_LOGICAL, true}, + {"-follow", T_OPTION, parse_follow, BFTW_FOLLOW_ALL, true}, {"-fprint", T_ACTION, parse_fprint}, {"-fprint0", T_ACTION, parse_fprint0}, {"-fprintf", T_ACTION, parse_fprintf}, @@ -3382,9 +3382,9 @@ void dump_cmdline(const struct cmdline *cmdline, enum debug_flags flag) { cfprintf(cerr, "${ex}%s${rs} ", cmdline->argv[0]); - if (cmdline->flags & BFTW_LOGICAL) { + if (cmdline->flags & BFTW_FOLLOW_ALL) { cfprintf(cerr, "${cyn}-L${rs} "); - } else if (cmdline->flags & BFTW_COMFOLLOW) { + } else if (cmdline->flags & BFTW_FOLLOW_ROOTS) { cfprintf(cerr, "${cyn}-H${rs} "); } else { cfprintf(cerr, "${cyn}-P${rs} "); @@ -3451,7 +3451,7 @@ void dump_cmdline(const struct cmdline *cmdline, enum debug_flags flag) { } else { cfprintf(cerr, "${blu}-nocolor${rs} "); } - if (cmdline->flags & BFTW_DEPTH) { + if (cmdline->flags & BFTW_POST_ORDER) { cfprintf(cerr, "${blu}-depth${rs} "); } if (cmdline->ignore_races) { @@ -3463,13 +3463,13 @@ void dump_cmdline(const struct cmdline *cmdline, enum debug_flags flag) { if (cmdline->maxdepth != INT_MAX) { cfprintf(cerr, "${blu}-maxdepth${rs} ${bld}%d${rs} ", cmdline->maxdepth); } - if (cmdline->flags & BFTW_MOUNT) { + if (cmdline->flags & BFTW_SKIP_MOUNTS) { cfprintf(cerr, "${blu}-mount${rs} "); } if (cmdline->unique) { cfprintf(cerr, "${blu}-unique${rs} "); } - if ((cmdline->flags & (BFTW_MOUNT | BFTW_XDEV)) == BFTW_XDEV) { + if ((cmdline->flags & (BFTW_SKIP_MOUNTS | BFTW_PRUNE_MOUNTS)) == BFTW_PRUNE_MOUNTS) { cfprintf(cerr, "${blu}-xdev${rs} "); } @@ -3656,7 +3656,7 @@ struct cmdline *parse_cmdline(int argc, char *argv[]) { } } - if ((cmdline->flags & BFTW_LOGICAL) && !cmdline->unique) { + if ((cmdline->flags & BFTW_FOLLOW_ALL) && !cmdline->unique) { // We need bftw() to detect cycles unless -unique does it for us cmdline->flags |= BFTW_DETECT_CYCLES; } |