freebsd-dev/usr.bin/find
Jilles Tjoelker 9d6d5a7131 find: Allow -delete to delete files given as arguments.
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
2013-08-02 14:14:23 +00:00
..
extern.h Add an option for finding sparse files. 2013-03-03 20:10:56 +00:00
find.1 Add an option for finding sparse files. 2013-03-03 20:10:56 +00:00
find.c find: Implement real -ignore_readdir_race. 2012-07-25 21:59:10 +00:00
find.h find: Include nanoseconds when comparing timestamps of files. 2013-03-17 22:51:58 +00:00
function.c find: Allow -delete to delete files given as arguments. 2013-08-02 14:14:23 +00:00
getdate.y Fix world after byacc import: 2012-05-22 16:33:10 +00:00
ls.c Fix usr.bin/ and usr.sbin/ build with a 64-bit ino_t. 2012-09-27 23:31:19 +00:00
main.c find: Run when cwd cannot be opened, except with -execdir or -delete. 2013-02-10 18:56:37 +00:00
Makefile Add the Clang specific -Wmissing-variable-declarations to WARNS=6. 2013-04-19 19:45:00 +00:00
misc.c Remove the advertising clause from UCB copyrighted files in usr.bin. This 2010-12-11 08:32:16 +00:00
operator.c Remove the advertising clause from UCB copyrighted files in usr.bin. This 2010-12-11 08:32:16 +00:00
option.c Add an option for finding sparse files. 2013-03-03 20:10:56 +00:00