summaryrefslogtreecommitdiffstats
path: root/usr.bin/find
Commit message (Collapse)AuthorAgeFilesLines
* find: Allow -delete to delete files given as arguments.jilles2013-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
* Add the Clang specific -Wmissing-variable-declarations to WARNS=6.ed2013-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@
* find: Include nanoseconds when comparing timestamps of files.jilles2013-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
* Add an option for finding sparse files.dwmalone2013-03-034-1/+31
| | | | | Reviewed by: iedowse MFC after: 3 weeks
* find: Run when cwd cannot be opened, except with -execdir or -delete.jilles2013-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.
* find: In -execdir ... {} +, only pass one file per invocation.jilles2013-02-101-1/+7
| | | | | | | This is inefficient but ensures that -execdir ... {} + does not mix files from different directories in one invocation; the command could not access some files. Files from the same directory should really be handled in one invocation but this is somewhat more complicated.
* Use .Nm instead of a self xrefeadler2012-11-191-4/+4
| | | | | Approved by: bcr (mentor) MFC after: 1 week
* Make it clear that amin and friends take + and - options.eadler2012-11-181-7/+27
| | | | | | | PR: docs/173265 Submitted by: Anton Shterenlikht <mexas@bristol.ac.uk> Approved by: bcr (mentor) MFC after: 3 days
* Fix usr.bin/ and usr.sbin/ build with a 64-bit ino_t.mdf2012-09-271-1/+1
| | | | Original code by: Gleb Kurtsou
* find: Do not pass fd to save current directory to child processes.jilles2012-09-261-1/+1
| | | | | | | This removes one of the two wrongly passed file descriptors. The other one appears to be from fts(3). MFC after: 1 week
* Note that -quit terminates successfully.des2012-09-101-1/+1
| | | | Requested by: jmg@
* Document -quit, four and a half years after it was implemented.des2012-09-091-1/+5
| | | | | MFC after: 3 days Pointy hat to: imp@
* find: Remove unnecessary and inconsistent initialization.jilles2012-07-311-1/+1
| | | | Submitted by: jhb
* find: Implement real -ignore_readdir_race.jilles2012-07-256-8/+38
| | | | | | | | | | If -ignore_readdir_race is present, [ENOENT] errors caused by deleting a file after find has read its name from a directory are ignored. Formerly, -ignore_readdir_race did nothing. PR: bin/169723 Submitted by: Valery Khromov and Andrey Ignatov
* find(1): Move description of -d option to -depth primary.jilles2012-06-131-30/+30
| | | | | | | | The nullary -depth primary is standard and the -d option provides little advantage. PR: docs/168885 MFC after: 1 week
* Add more description and clarification about the -depth and -d options inissyl02012-06-101-4/+5
| | | | | | | | | | both places where they are mentioned in find(1). Discussed with: dougb PR: docs/168885 Reported by: Ronald F. Guilmette (rfg at tristatelogic dot com) Approved by: gabor (mentor) MFC after: 3 days
* Fix style nit: don't use leading zero for dates in .Ddeadler2012-06-051-1/+1
| | | | | | Prompted by: brueffer Approved by: brueffer MFC after: 3 days
* Document the limitations of the -delete primaryeadler2012-06-021-1/+4
| | | | | | | | PR: bin/166554 Submitted by: Richard Kettlewell <rjk@greenend.org.uk> Discussed with: jilles Approved by: bcr MFC after: 3 days
* Fix world after byacc import:bapt2012-05-221-2/+0
| | | | | | | | - old yacc(1) use to magicially append stdlib.h, while new one don't - new yacc(1) do declare yyparse by itself, fix redundant declaration of 'yyparse' Approved by: des (mentor)
* Remove trailing whitespace per mdoc lint warningeadler2012-03-291-12/+12
| | | | | | | Disussed with: gavin No objection from: doc Approved by: joel MFC after: 3 days
* Remove superfluous paragraph macro.joel2012-03-251-1/+0
|
* Replace char copyright[] by static const char copyright[].ed2011-12-101-1/+1
| | | | It seems the latter is used throughout the tree.
* Get rid of major/minor number distinction.ed2011-09-282-4/+3
| | | | | | | | | | | | | | | | | | | | | | As of FreeBSD 6, devices can only be opened through devfs. These device nodes don't have major and minor numbers anymore. The st_rdev field in struct stat is simply based a copy of st_ino. Simply display device numbers as hexadecimal, using "%#jx". This is allowed by POSIX, since it explicitly states things like the following (example taken from ls(1)): "If the file is a character special or block special file, the size of the file may be replaced with implementation-defined information associated with the device in question." This makes the output of these commands more compact. For example, ls(1) now uses approximately four columns less. While there, simplify the column length calculation from ls(1) by calling snprintf() with a NULL buffer. Don't be afraid; if needed one can still obtain individual major/minor numbers using stat(1).
* Using statfs.f_fstypename rather than statfs.f_type whilst performing fstypeavatar2011-06-131-20/+6
| | | | | | | | comparsion as nullfs will copy f_type from underlayer FS. PR: bin/156258 Submitted by: Marcin Wisnicki <mwisnicki+freebsd@gmail.com> MFC after: 1 month
* find: Exit if there is an unknown option.jilles2011-06-041-1/+1
| | | | | | | | | | | | Ignoring the parameter with the unknown options is unlikely to be what was intended. Example: find -n . Note that things like find -n already caused an exit, equivalent to "find" by itself.
* find: If a part of an expression is unknown, do not call it an option.jilles2011-05-271-1/+1
| | | | | | | | | | | Although most of the primaries and operators start with "-", they are not options. Examples: find . -xyz find . -name xyz -or bad MFC after: 1 week
* Move the explanation of using arguments for the PRIMARIES abovegjb2011-03-101-12/+12
| | | | | | | | | the list of PRIMARIES. PR: 151812 Submitted by: Jay (jouellette of gmail com) Patch by: eadler MFC after: 1 week
* Remove the advertising clause from UCB copyrighted files in usr.bin. Thisjoel2010-12-1110-40/+0
| | | | | | | | | is in accordance with the information provided at ftp://ftp.cs.berkeley.edu/pub/4bsd/README.Impt.License.Change Also add $FreeBSD$ to a few files to keep svn happy. Discussed with: imp, rwatson
* Don't error out while searching for empty directories.kevlo2010-12-021-1/+1
| | | | Submitted by: Bakul Shah <bakul at bitblocks dot com>
* Revert r207677 which is considered a violation of style(9).delphij2010-05-067-16/+46
| | | | | Pointed out by: bde Pointy hat to: delphij
* Move SCCS tags to comments as they were already #if 0'ed.delphij2010-05-057-44/+14
|
* Better way to find out available file system types is to use lsvfs(1).pjd2010-03-161-6/+4
| | | | | | | | Using 'sysctl vfs' is not only ugly, but is also not reliable - not all file system types create entries in vfs sysctl tree. Reviewed by: imp MFC after: 1 week
* The -newerXB option was being interpreted the same as the -newerXm optiongavin2010-02-141-0/+2
| | | | | | | | as a check for F_TIME2_B was missing. Fix this. PR: bin/138245 Submitted by: "David E. Cross" <crossd cs.rpi.edu> MFC after: 1 month
* Remove unneeded CFLAGS.ed2010-02-101-1/+0
|
* Don't let find(1) depend on struct timeb.ed2010-02-093-42/+31
| | | | | | This structure is deprecated and only used by ftime(2), which is part of libcompat. The second argument of get_date() is unused, which means we can just remove it entirely.
* Build usr.bin/ with WARNS=6 by default.ed2010-01-021-1/+0
| | | | Also add some missing $FreeBSD$ to keep svn happy.
* ANSIfy almost all applications that use WARNS=6.ed2009-12-291-1/+1
| | | | | | | I was considering committing all these patches one by one, but as discussed with brooks@, there is no need to do this. If we ever need/want to merge these changes back, it is still possible to do this per application.
* Revert most part of 200420 as requested, as more review and polish isdelphij2009-12-136-0/+6
| | | | needed.
* Remove unneeded header includes from usr.bin/ except contributed code.delphij2009-12-116-6/+0
| | | | Tested with: make universe
* Update find(1) man page for -L/-delete interaction.jilles2009-09-201-1/+2
| | | | | | | | | It is a bit unfortunate that the example to delete broken symlinks now uses rm(1), but allowing this with -delete would require fixing fts(3) to not imply FTS_NOCHDIR if FTS_LOGICAL is given (or hacks in the -delete option). PR: bin/90687 MFC after: 2 weeks
* Add NFSv4 ACL support to find(1).trasz2009-09-041-25/+35
| | | | Reviewed by: rwatson
* rm, find -delete: fix removing symlinks with uchg/uappnd set.jilles2009-05-301-1/+1
| | | | | | | | | | | | Formerly, this tried to clear the flags on the symlink's target instead of the symlink itself. As before, this only happens for root or for the unlink(1) variant of rm. PR: bin/111226 (part of) Submitted by: Martin Kammerhofer Approved by: ed (mentor) MFC after: 3 weeks
* find: do not silently disable -L when -delete is usedavg2009-05-191-5/+5
| | | | | | | | | | | | | | | | | | First of all, current behavior is not documented and confusing, and it can be very dangerous in the following sequence: find -L . -type l find -L . -type l -delete (the second line is even suggested by find(1)). Instead simply refuse to proceed when -L and -delete are both used. A descriptive error message is provided. The following command can be safely used to remove broken links: find -L . -type l -print0 | xargs rm -0 To do: update find(1) PR: bin/90687 Obtained from: Anatoli Klassen <anatoli@aksoft.net> Approved by: jhb (mentor)
* Fix SYNOPSIS and usage().ru2008-03-032-9/+10
|
* Bump .Dd for revisions 1.83 and 1.84.ceri2008-02-241-1/+1
|
* Tag -ilname and -lname as GNU extensions.imp2008-02-241-1/+4
| | | | | Correct their descriptions to indicate that it is the contents of the symbolic link that are matched.
* The matching in -lname and -ilname are on the contents of the linkimp2008-02-241-5/+10
| | | | | | | | itself, not on the type of the file. As such, do a readlink to get the symbolic link's contents and fail to match if the path isn't a symbolic link. Pointed out by: des@
* Implement a number of primaries present in GNU find, but not presentimp2008-02-235-5/+159
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | in our find. The following are nops because they aren't relevant to our find: -ignore_readdir_race -noignore_readdir_race -noleaf The following aliaes were created: -gid -> -group [2] -uid -> -user [2] -wholename -> -path -iwholename -> ipath -mount -> -xdev -d -> -depth [1] The following new primaries were created: -lname like -name, but matches symbolic links only) -ilname like -lname but case insensitive -quit exit(0) -samefile returns true for hard links to the specified file -true Always true I changed one primary to match GNU find since I think our use of it violates POLA -false Always false (was an alias for -not!) Also, document the '+' modifier for -execdir, as well as all of the above. This was previously implemented. Document the remaining 7 primaries that are in GNU find, but aren't yet implemented in find(1) [1] This was done in GNU find for compatibility with FreeBSD, yet they mixed up command line args and primary args. [2] -uid/-gid in GNU find ONLY takes a numeric arg, but that arg does the normal range thing that. GNU find -user and -uid also take a numberic arg, but don't do the range processing. find(1) does both for -user and -group, so making -uid and -gid aliases is compatible for all non-error cases used in GNU find. While not perfect emulation, this seems a reasonable thing for us.
* Check in some insignificant fixes obtained as a result ofru2007-02-281-18/+19
| | | | the translation work.
* Fix the description of the -Btime primary.ru2006-12-131-3/+3
| | | | Noticed by: Vadim Goncharov <vadimnuclight tpu.ru>
OpenPOWER on IntegriCloud