aboutsummaryrefslogtreecommitdiff
path: root/usr.bin/find
Commit message (Collapse)AuthorAgeFilesLines
* Use the Ic macro for find(1) primaries consistentlyMateusz Piotrowski2020-04-181-2/+2
| | | | | | | MFC after: 3 days Notes: svn path=/head/; revision=360074
* Fix whiteout support in find(1)Oleksandr Tymoshenko2019-01-281-1/+3
| | | | | | | | | | | | find(1) ignores -type w passed to it. With this patch find(1) properly identifies and prints whiteouts. PR: 126384, 156703 Submitted by: oleg@mamontov.net MFC after: 1 week Notes: svn path=/head/; revision=343516
* find(1): remove empty else conditionEitan Adler2018-07-252-2/+0
| | | | | | | reported by: brooks Notes: svn path=/head/; revision=336700
* find(1): use correct type for readlinkEitan Adler2018-07-011-1/+1
| | | | Notes: svn path=/head/; revision=335852
* find(1): deLINTifyEitan Adler2018-07-017-16/+0
| | | | Notes: svn path=/head/; revision=335851
* find(1): remove portability ifdefsEitan Adler2018-07-011-11/+0
| | | | | | | | | This code isn't designed to be particularly portable outside of FreeBSD. To be more specific it doesn't make much sense to support compiling find(1) on VMS. Notes: svn path=/head/; revision=335849
* Allow compiling usr.bin/find on Linux and MacAlex Richardson2018-02-066-1/+62
| | | | | | | | | | | | | | | | When building FreeBSD the makefiles invoke find with various flags such as `-s` that aren't supported in the native /usr/bin/find. To fix this I build the FreeBSD version of find and use that when crossbuilding. Inserting lots if #ifdefs in the code is rather ugly but I don't see a better solution. Reviewed By: brooks (mentor) Approved By: jhb (mentor) Differential Revision: https://reviews.freebsd.org/D13306 Notes: svn path=/head/; revision=328933
* find: Speed up tests by using touch -d instead of sleep for timestampsJilles Tjoelker2018-01-041-4/+3
| | | | | | | I have verified that the tests still detect the absence of the r327362 fix. Notes: svn path=/head/; revision=327565
* find: Link tests to the buildJilles Tjoelker2017-12-311-2/+4
| | | | Notes: svn path=/head/; revision=327440
* find(1): Fix -newer and -samefile to conform to POSIX[0]Conrad Meyer2017-12-294-2/+93
| | | | | | | | | | | | | | | | | By default, or with the -P flag, find(1) should evaluate paths "physically." For symlinks, this means using the link itself instead of the target. Historically (since the import of BSD 4.4-lite from CSRG), find(1) has failed to refer to the link itself, at least for -newer and -samefile. [0]: http://pubs.opengroup.org/onlinepubs/9699919799/utilities/find.html PR: 222698 Reported by: Harald Schmalzbauer <bugzilla.freebsd AT omnilan.de> Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=327362
* find(1): remove unused variableEitan Adler2017-12-132-2/+1
| | | | Notes: svn path=/head/; revision=326816
* General further adoption of SPDX licensing ID tags.Pedro F. Giffuni2017-11-209-1/+19
| | | | | | | | | | | | | | | | | Mainly focus on files that use BSD 3-Clause license. The Software Package Data Exchange (SPDX) group provides a specification to make it easier for automated tools to detect and summarize well known opensource licenses. We are gradually adopting the specification, noting that the tags are considered only advisory and do not, in any way, superceed or replace the license texts. Special thanks to Wind River for providing access to "The Duke of Highlander" tool: an older (2014) run over FreeBSD tree was useful as a starting point. Notes: svn path=/head/; revision=326025
* find(1): Don't treat statfs() error as fatal in f_fstype, which can happenXin LI2017-11-111-2/+7
| | | | | | | | | | | | | | | when a directory is removed in the middle of find. Instead of a full err(), allow find to continue, plus print a warning with exitstatus set when appropriate. Reported by: 100.chksetuid via gordon Reviewed by: jilles MFC after: 1 month Differential Revision: https://reviews.freebsd.org/D13024 Notes: svn path=/head/; revision=325723
* DIRDEPS_BUILD: Update dependencies.Bryan Drewery2017-10-311-1/+0
| | | | | | | Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=325188
* Renumber copyright clause 4Warner Losh2017-02-2810-10/+10
| | | | | | | | | | | | Renumber cluase 4 to 3, per what everybody else did when BSD granted them permission to remove clause 3. My insistance on keeping the same numbering for legal reasons is too pedantic, so give up on that point. Submitted by: Jan Schaumann <jschauma@stevens.edu> Pull Request: https://github.com/freebsd/freebsd/pull/96 Notes: svn path=/head/; revision=314436
* Improve wording when describing -mmin.Sevan Janiyan2017-01-241-1/+2
| | | | | | | | | | | PR: 215922 Submitted by: danielsh AT apache DOT org Approved by: bcr (mentor) MFC after: 5 days Differential Revision: https://reviews.freebsd.org/D9313 Notes: svn path=/head/; revision=312692
* Use type-independent formats for printing nlink_t and ino_t.Konstantin Belousov2017-01-061-1/+2
| | | | | | | | | | Extracted from: ino64 work by gleb, mckusick Discussed with: mckusick Sponsored by: The FreeBSD Foundation MFC after: 1 week Notes: svn path=/head/; revision=311522
* Use NULL instead of 0 for pointers.Marcelo Araujo2016-04-181-1/+1
| | | | | | | MFC after: 2 weeks. Notes: svn path=/head/; revision=298189
* DIRDEPS_BUILD: Regenerate without local dependencies.Bryan Drewery2016-02-241-2/+0
| | | | | | | | | | | These are no longer needed after the recent 'beforebuild: depend' changes and hooking DIRDEPS_BUILD into a subset of FAST_DEPEND which supports skipping 'make depend'. Sponsored by: EMC / Isilon Storage Division Notes: svn path=/head/; revision=295989
* find: Fix segfault with very long path in -exec/-ok ... {} \;.Jilles Tjoelker2015-08-052-15/+25
| | | | | | | | | | | | | | | | | If the resulting argument is longer than MAXPATHLEN, realloc() was called to extend the space, but the new pointer was not correctly stored. Different from what OpenBSD has done, rewrite brace_subst() to calculate the necessary space first and realloc() at most once. As before, the e_len fields are not updated in case of a realloc. Therefore, a following long argument will do another realloc. PR: 201750 MFC after: 1 week Notes: svn path=/head/; revision=286344
* new dependsSimon J. Gerraty2015-06-161-0/+1
| | | | Notes: svn path=/head/; revision=284481
* Add META_MODE support.Simon J. Gerraty2015-06-131-0/+20
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | Off by default, build behaves normally. WITH_META_MODE we get auto objdir creation, the ability to start build from anywhere in the tree. Still need to add real targets under targets/ to build packages. Differential Revision: D2796 Reviewed by: brooks imp Notes: svn path=/head/; revision=284345
| * dirdeps.mk now sets DEP_RELDIRSimon J. Gerraty2015-06-081-2/+0
| | | | | | | | Notes: svn path=/projects/bmake/; revision=284172
| * Merge sync of headSimon J. Gerraty2015-05-271-1/+1
| |\ | |/ |/| | | Notes: svn path=/projects/bmake/; revision=283595
| * Merge from head@274682Simon J. Gerraty2014-11-191-1/+1
| |\ | | | | | | | | | Notes: svn path=/projects/bmake/; revision=274683
| * | Updated dependenciesSimon J. Gerraty2014-05-161-1/+0
| | | | | | | | | | | | Notes: svn path=/projects/bmake/; revision=266219
| * | Updated dependenciesSimon J. Gerraty2014-05-101-0/+2
| | | | | | | | | | | | Notes: svn path=/projects/bmake/; revision=265802
| * | Merge headSimon J. Gerraty2014-04-285-16/+59
| |\ \ | | | | | | | | | | | | Notes: svn path=/projects/bmake/; revision=265044
| * \ \ Merge from headSimon J. Gerraty2013-09-052-1/+4
| |\ \ \ | | | | | | | | | | | | | | | Notes: svn path=/projects/bmake/; revision=255263
| * \ \ \ sync from headSimon J. Gerraty2013-04-126-24/+83
| |\ \ \ \ | | | | | | | | | | | | | | | | | | Notes: svn path=/projects/bmake/; revision=249429
| * | | | | Updated dependenciesSimon J. Gerraty2013-03-111-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | Notes: svn path=/projects/bmake/; revision=248169
| * | | | | Updated dependenciesSimon J. Gerraty2013-02-161-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | Notes: svn path=/projects/bmake/; revision=246868
| * | | | | Sync with HEAD.David E. O'Brien2013-02-081-11/+31
| |\ \ \ \ \ | | | | | | | | | | | | | | | | | | | | | Notes: svn path=/projects/bmake/; revision=246555
| * \ \ \ \ \ Sync from headSimon J. Gerraty2012-11-047-39/+77
| |\ \ \ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | Notes: svn path=/projects/bmake/; revision=242545
| * | | | | | | Sync FreeBSD's bmake branch with Juniper's internal bmake branch.Marcel Moolenaar2012-08-221-0/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Requested by: Simon Gerraty <sjg@juniper.net> Notes: svn path=/projects/bmake/; revision=239572
* | | | | | | | find.1: Add missing whitespace:Eitan Adler2015-04-201-1/+1
| |_|_|_|_|_|/ |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Obtained from: Dragonfly (dee38d02d51cc8316f82b0263158d2546f2398bc) Notes: svn path=/head/; revision=281759
* | | | | | | Correct scale factor for T terabyte suffixEd Maste2014-10-081-1/+1
| |_|_|_|_|/ |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | PR: 194250 MFC after: 3 days Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=272762
* | | | | | Avoid double free in f_acl().Christian Brueffer2014-04-131-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | CID: 1018508 Found with: Coverity Prevent(tm) MFC after: 1 week Notes: svn path=/head/; revision=264418
* | | | | | find: Return normal exit status from -quit.Jilles Tjoelker2014-04-132-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If there was an error, make the exit status reflect this even if -quit caused the exit. Formerly, -quit always caused exit(0). GNU find does the same. Notes: svn path=/head/; revision=264411
* | | | | | find: Correctly propagate -exec/-execdir ... {} + exit status.Jilles Tjoelker2014-04-125-7/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As per POSIX, the -exec ... {} + primary always returns true, but a non-zero exit status causes find to return a non-zero exit status itself. GNU does the same, and also for -execdir ... {} +. It does not make much sense to return false from the primary only when the child process happens to be run. The behaviour for -exec/-execdir ... ; remains unchanged: the primary returns true or false depending on the exit status, and find's exit status is unaffected. Notes: svn path=/head/; revision=264387
* | | | | | find: Treat errno from fts_read() more carefully.Jilles Tjoelker2014-04-061-4/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | fts_read() leaves errno unchanged on EOF and sets it on error, so set errno to 0 before calling it. Also, don't trust finish_execplus() to leave errno unchanged. Notes: svn path=/head/; revision=264201
* | | | | | find: When performing -quit, finish pending -exec ... + command lines.Jilles Tjoelker2014-03-161-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This avoids unexpected partial processing when a find command uses both -quit and -exec ... +. GNU find does the same. MFC after: 1 week Notes: svn path=/head/; revision=263244
* | | | | | find: Allow -type d without statting everything.Jilles Tjoelker2014-01-111-2/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | fts(3) detects directories even in FTS_NOSTAT mode (so it can descend into them). No functional change is intended, but find commands that use -type d but no primaries that still require stat/lstat calls make considerably fewer system calls. Notes: svn path=/head/; revision=260555
* | | | | | find: Fix two more problems with -lname and -ilname:Jilles Tjoelker2014-01-052-2/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Do not match symlinks that are followed because of -H or -L. This is explicitly documented in GNU find's info file and is like -type l. * Fix matching symlinks in subdirectories when fts changes directories. Also, avoid some readlink() calls on files that are obviously not symlinks (because of fts(3) restrictions, not all of them). MFC after: 1 week Notes: svn path=/head/; revision=260355
* | | | | | find: Fix -lname and -ilname.Jilles Tjoelker2014-01-051-2/+5
| |_|_|_|/ |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The code did not take into account that readlink() does not add a terminating '\0', and therefore did not work reliably. As before, symlinks of length PATH_MAX or more are not handled correctly. (These can only be created on other operating systems.) PR: bin/185393 Submitted by: Ben Reser (original version) MFC after: 1 week Notes: svn path=/head/; revision=260336
* | | | | find: Allow -delete to delete files given as arguments.Jilles Tjoelker2013-08-021-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Formerly, a command like find dir1/dir2 -delete would delete everything under dir1/dir2 but not dir1/dir2 itself. When -L is not specified and "." can be opened, the fts(3) code underlying find(1) is careful to avoid following symlinks or being dropped in different locations by moving the directory fts is currently traversing. If a problematic concurrent modification is detected, fts will not enter the directory or abort. Files found in the search are returned via the current working directory and a pathname not containing a slash. For paranoia, find(1) verifies this when -delete is used. However, it is too paranoid about the root of the traversal. It is already assumed that the initial pathname does not refer to directories or symlinks that might be replaced by untrusted users; otherwise, the whole traversal would be unsafe. Therefore, it is not necessary to do the check for fts_level == FTS_ROOTLEVEL. Deleting the pathnames given as arguments can be prevented without error messages using -mindepth 1 or by changing directory and passing "." as argument to find. This works in the old as well as the new version of find. Tested by: Kurt Lidl Reviewed by: jhb Notes: svn path=/head/; revision=253886
* | | | | Add the Clang specific -Wmissing-variable-declarations to WARNS=6.Ed Schouten2013-04-191-0/+2
| |_|_|/ |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This compiler flag enforces that that people either mark variables static or use an external declarations for the variable, similar to how -Wmissing-prototypes works for functions. Due to the fact that Yacc/Lex generate code that cannot trivially be changed to not warn because of this (lots of yy* variables), add a NO_WMISSING_VARIABLE_DECLARATIONS that can be used to turn off this specific compiler warning. Announced on: toolchain@ Notes: svn path=/head/; revision=249657
* | | | find: Include nanoseconds when comparing timestamps of files.Jilles Tjoelker2013-03-172-20/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When comparing to the timestamp of a given file using -newer, -Xnewer and -newerXY (where X and Y are one of m, c, a, B), include nanoseconds in the comparison. The primaries that compare a timestamp of a file to a given value (-Xmin, -Xtime, -newerXt) continue to compare times in whole seconds. Note that the default value 0 of vfs.timestamp_precision almost always causes the nanoseconds part to be 0. However, touch -d can set a timestamp to the microsecond regardless of that sysctl. MFC after: 1 week Notes: svn path=/head/; revision=248446
* | | | Add an option for finding sparse files.David Malone2013-03-034-1/+31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Reviewed by: iedowse MFC after: 3 weeks Notes: svn path=/head/; revision=247730
* | | | find: Run when cwd cannot be opened, except with -execdir or -delete.Jilles Tjoelker2013-02-102-2/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | fts(3) can run (albeit more slowly and imposing the {PATH_MAX} limit) when the current directory cannot be opened. Therefore, do not make a failure to open the current directory (for returning to it later in -exec) fatal. If -execdir or -delete are used, the expectation is that fts(3) will use chdir to avoid race conditions (except for -execdir with -L). Do not break this expectation any more than it already is by still failing if the current directory cannot be opened. Notes: svn path=/head/; revision=246628