[Bug 222698] find(1)'s -newer expression doesn't work with symbolic links if '-P' (the default) is requested.
bugzilla-noreply at freebsd.org
bugzilla-noreply at freebsd.org
Thu Dec 28 19:57:47 UTC 2017
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=222698
--- Comment #4 from Conrad Meyer <cem at freebsd.org> ---
This change ought to be sufficient to fix -newer:
--- a/usr.bin/find/function.c
+++ b/usr.bin/find/function.c
@@ -1201,6 +1201,7 @@ c_newer(OPTION *option, char ***argvp)
char *fn_or_tspec;
PLAN *new;
struct stat sb;
+ int error;
fn_or_tspec = nextarg(option, argvp);
ftsoptions &= ~FTS_NOSTAT;
@@ -1214,7 +1215,11 @@ c_newer(OPTION *option, char ***argvp)
/* Use the seconds only in the comparison. */
new->t_data.tv_nsec = 999999999;
} else {
- if (stat(fn_or_tspec, &sb))
+ if (ftsoptions & FTS_PHYSICAL)
+ error = lstat(fn_or_tspec, &sb);
+ else
+ error = stat(fn_or_tspec, &sb);
+ if (error != 0)
err(1, "%s", fn_or_tspec);
if (option->flags & F_TIME2_C)
new->t_data = sb.st_ctim;
However, -samefile is similarly broken. Here's a patch for that part:
--- a/usr.bin/find/function.c
+++ b/usr.bin/find/function.c
@@ -1066,12 +1066,17 @@ c_samefile(OPTION *option, char ***argvp)
char *fn;
PLAN *new;
struct stat sb;
+ int error;
fn = nextarg(option, argvp);
ftsoptions &= ~FTS_NOSTAT;
new = palloc(option);
- if (stat(fn, &sb))
+ if (ftsoptions & FTS_PHYSICAL)
+ error = lstat(fn, &sb);
+ else
+ error = stat(fn, &sb);
+ if (error != 0)
err(1, "%s", fn);
new->i_data = sb.st_ino;
return new;
--
You are receiving this mail because:
You are the assignee for the bug.
More information about the freebsd-bugs
mailing list