summaryrefslogtreecommitdiffstats
path: root/parse.c
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2016-02-04 23:12:08 -0500
committerTavian Barnes <tavianator@tavianator.com>2016-02-04 23:12:08 -0500
commit0f91c5861cacaeb17729b7727d07260273345393 (patch)
tree8348044cc4697e2576a401fe81c2d5bca7dbc0eb /parse.c
parentc9905877cb06f71c4523e4f4875bf549b6b54060 (diff)
downloadbfs-0f91c5861cacaeb17729b7727d07260273345393.tar.xz
Implement -P and -H.
Diffstat (limited to 'parse.c')
-rw-r--r--parse.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/parse.c b/parse.c
index 413282a..93657c8 100644
--- a/parse.c
+++ b/parse.c
@@ -344,7 +344,11 @@ static struct expr *parse_acnewer(struct parser_state *state, const char *option
}
struct stat sb;
- if (fstatat(AT_FDCWD, expr->sdata, &sb, AT_SYMLINK_NOFOLLOW) != 0) {
+
+ bool follow = state->cl->flags & BFTW_FOLLOW_ROOT;
+ int flags = follow ? 0 : AT_SYMLINK_NOFOLLOW;
+
+ if (fstatat(AT_FDCWD, expr->sdata, &sb, flags) != 0) {
print_error(NULL, expr->sdata, errno);
free_expr(expr);
return NULL;
@@ -465,6 +469,20 @@ static struct expr *parse_literal(struct parser_state *state) {
}
switch (arg[1]) {
+ case 'P':
+ if (strcmp(arg, "-P") == 0) {
+ state->cl->flags &= ~BFTW_FOLLOW_ROOT;
+ return new_option(state, arg);
+ }
+ break;
+
+ case 'H':
+ if (strcmp(arg, "-H") == 0) {
+ state->cl->flags |= BFTW_FOLLOW_ROOT;
+ return new_option(state, arg);
+ }
+ break;
+
case 'a':
if (strcmp(arg, "-amin") == 0) {
return parse_acmtime(state, arg, ATIME, MINUTES);