Commit graph

274 commits

Author SHA1 Message Date
Ricardo Branco e4b646ce16 find: Add -readable, -writable & -executable options
Reviewed by:	jhb, Mina Galić
Pull Request:	https://github.com/freebsd/freebsd-src/pull/1080
2024-01-21 17:33:46 -08:00
Ricardo Branco 2a121b97e9 find: Allow '/' to be used with -perm for GNU compatibility
In 2005, Gnu find deprecated '+' as the leading character for the -perm
argument, instead preferring '/' with the same meaning. Implement that
behavior here, and document it in the man page.

Reviewed by: imp, emaste
Pull Request: https://github.com/freebsd/freebsd-src/pull/1060
2024-01-15 11:47:24 -07:00
Baptiste Daroussin 91dc237466 find: fix build on 32bits 2024-01-12 07:34:28 +01:00
Goran Mekić d06a00963b find: add SIGINFO handler
Print number of files processed and path currently being processed on
SIGINFO.

Reviewed by:	des, asomers
Sponsored by:	Axcient
MFC after:	2 weeks
Differential Revision: https://reviews.freebsd.org/D43380
2024-01-11 16:37:14 -07:00
Dag-Erling Smørgrav 45438f9c8b find: Add a warning about -delete.
MFC after:	1 week
Sponsored by:	Klara, Inc.
Reviewed by:	pauamma_gundo.com
Differential Revision:	https://reviews.freebsd.org/D43162
2023-12-22 00:41:16 +01:00
Warner Losh 5e3934b15a usr.bin: Automated cleanup of cdefs and other formatting
Apply the following automated changes to try to eliminate
no-longer-needed sys/cdefs.h includes as well as now-empty
blank lines in a row.

Remove /^#if.*\n#endif.*\n#include\s+<sys/cdefs.h>.*\n/
Remove /\n+#include\s+<sys/cdefs.h>.*\n+#if.*\n#endif.*\n+/
Remove /\n+#if.*\n#endif.*\n+/
Remove /^#if.*\n#endif.*\n/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/types.h>/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/param.h>/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/capsicum.h>/

Sponsored by:		Netflix
2023-11-26 22:24:01 -07:00
Warner Losh 0b8224d1cc Remove copyright strings ifdef'd out
We've ifdef'd out the copyright strings for some time now. Go ahead and
remove the ifdefs. Plus whatever other detritis was left over from other
recent removals. These copyright strings are present in the comments and
are largely from CSRG's attempt at adding their copyright to every
binary file (which modern interpretations of the license doesn't
require).

Sponsored by:		Netflix
2023-11-26 22:23:58 -07:00
Warner Losh 5b31cc94b1 sccs: Manual changes
For the uncommon items: Go through the tree and remove sccs tags that
didn't fit any nice pattern. If in the neighborhood, other SCM tags were
removed when they were detritis of long-ago CVS somehow in the early
mists of the project. Some adjacent copyrights stringswere removed (they
duplicated the copyright notices in the file). This also removed
non-standard formations of omission of SCCS tags (usually by adding an
extra #if 0 somewhere.

After this commit, a number of strings tagged with the 'what' @(#)
prefix remain, but they are primarily copyright notices.

Sponsored by:		Netflix
2023-11-26 22:23:58 -07:00
Warner Losh bdcbfde31e usr.bin: Remove ancient SCCS tags.
Remove ancient SCCS tags from the tree, automated scripting, with two
minor fixup to keep things compiling. All the common forms in the tree
were removed with a perl script.

Sponsored by:		Netflix
2023-11-26 22:23:30 -07:00
Warner Losh b2c76c41be Remove $FreeBSD$: one-line nroff pattern
Remove /^\.\\"\s*\$FreeBSD\$$\n/
2023-08-16 11:55:15 -06:00
Warner Losh d0b2dbfa0e Remove $FreeBSD$: one-line sh pattern
Remove /^\s*#[#!]?\s*\$FreeBSD\$.*$\n/
2023-08-16 11:55:03 -06:00
Warner Losh 1d386b48a5 Remove $FreeBSD$: one-line .c pattern
Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
2023-08-16 11:54:42 -06:00
Warner Losh 42b388439b Remove $FreeBSD$: one-line .h pattern
Remove /^\s*\*+\s*\$FreeBSD\$.*$\n/
2023-08-16 11:54:23 -06:00
Alfonso Gregory a1b6427a97 Mark usage function as __dead2 in programs where it does not return
In most cases, usage does not return, so mark them as __dead2. For the
cases where they do return, they have not been marked __dead2.

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/735
2023-07-07 10:45:18 -06:00
Simon J. Gerraty d9a4274795 Update/fix Makefile.depend for userland 2023-04-18 17:14:23 -07:00
Dag-Erling Smørgrav 14ebab25e1 find: Logic nit in man page.
Arguments follow primaries, not the other way around.

MFC after:	1 week
Sponsored by:	Klara, Inc.

Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D38173
2023-01-24 09:53:35 +01:00
Kirk McKusick 927f8d8bbb Handle NULL return from localtime(3) in ls(1) and find(1)
The ls(1) (with -l option) and find(1) (with -ls option) utilties
segment fault when operating on files with very large modification
times. A recent disk corruption set a spurious bit in the mtime
field of one of my files to 0x8000000630b0167 (576460753965089127)
which is in year 18,266,940,962. I discovered the problem when
running fsck_ffs(8) which uses ctime(3) to convert it to a readable
format. Ctime cannot fit the year into its four character field, so
returns ??? ??? ?? ??:??:?? ???? (typically Thu Nov 24 18:22:48 2021).

With the filesystem mounted, I used `ls -l' to see how it would
report the modification time and it segment faulted. The find(1)
program also segment faulted (see script below). Both these utilities
call the localtime(3) function to decode the modification time.
Localtime(3) returns a pointer to a struct tm (which breaks things
out into its component pieces: year, month, day, hour, minute,
second). The ls(1) and find(1) utilities then print out the date
based on the appropriate fields in the returned tm structure.

Although not documented in the localtime(3) manual page, localtime(3)
returns a NULL pointer if the passed in time translates to a year
that will not fit in an "int" (which if "int" is 32-bits cannot
hold the year 18,266,940,962). Since ls(1) and find(1) do not check
for a NULL struct tm * return from localtime(3), they segment fault
when they try to dereference it.

When localtime(3) returns NULL, the attached patches produce a date
string of "bad date val". This string is chosen because it has the
same number of characters (12) and white spaces (2) as the usual
date string, for example "Sep 3 22:06" or "May 15 2017".

The most recent ANSI standard for localtime(3) does say that localtime(3)
can return NULL (see https://pubs.opengroup.org/onlinepubs/9699919799/
and enter localtime in the search box). Our localtime(3) man page should
be updated to indicate that NULL is a possible return. More importantly,
there are over 100 uses of localtime(3) in the FreeBSD source tree (see
Differential Revision D36474 for the list). Most do not check for a NULL
return from localtime(3).

Reported by:  Peter Holm
Reviewed by:  kib, Chuck Silvers, Warner Losh
MFC after:    2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D36474
2022-09-09 14:30:42 -07:00
Gordon Bergling 93b8510c36 find.1: Correct the markup
- ASCII is an acronym and there is no ascii(8) manual page
- Reference ascii(7) in the SEE ALSO section

Reported by:	karels
X-MFC with:	321dc6ee7e
2022-08-02 08:33:20 +02:00
Gordon Bergling 321dc6ee7e find.1: Fix mandoc warnings and mention a useful manpage
- new sentence, new line
- unknown AT&T UNIX version: At v7
- no blank before trailing delimiter
- reference the ASCII(8) manual page

MFC after:	5 days
2022-07-31 16:38:10 +02:00
Eugene Grosbein d6054ee652 find.1: small language fix after previous change
collate -> collation
2022-07-22 18:46:38 +07:00
Eugene Grosbein 26a329f49f find.1: explain why "find -s" may differ from "find | sort"
In short, that's because a directory name may end
with a character that goes before slash (/).

MFC after:	1 week
2022-07-22 18:39:47 +07:00
Emmanuel Vadot 93c4369096 pkgbase: Put more binaries/lib in runtime
Move some needed binaries/libs from FreeBSD-utilities to FreeBSD_runtime.
This is everything needed to boot to multiuser with FreeBSD-rc installed.

MFC after:	2 weeks
Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D33435
2021-12-21 10:17:27 +01:00
Felix Johnson 52dbe1a0f4 find(1): Update date format reference and remove cvs(1) references
cvs(1) is not installed by default. Change the date format reference to
note that find(1) understands ISO8601 and RFC822 date formats. Also
remove references to cvs(1).

PR:		254894
MFC after:	3 days
Reported by:	danielsh@apache.org
2021-11-08 01:14:58 -05:00
Ceri Davies 82483ea7ad find(1): Document the -f option
PR:	223127
Reported by:	Mathieu Arnold <mat at FreeBSD dot org>
Reviewed by:	bcr, gbe
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D30215
2021-05-13 10:10:22 +02:00
Gordon Bergling a9275d996c ls(1): Refine the HISTORY within the manual page.
A simple find command appeared in Version 1 AT&T UNIX and was removed in
Version 3 AT&T UNIX. It was rewritten for Version 5 AT&T UNIX and later
be enhanced for the Programmer's Workbench (PWB). These changes were
later incorporated in AT&T UNIX v7.

Reviewed by:	imp
MFC after:	1 week
2021-03-13 19:28:26 +01:00
Daniel Ebdrup Jensen 75e6f664c4 find(1): Mark -not as an extensions to POSIX
While here, change mdoc macro from Ic to Fl.

PR:		253499
Reported by:	Michael Siegel <bugcounterism at malbolge.net>
2021-02-23 17:15:35 +01:00
Mateusz Piotrowski 93e0e298b9 Use the Ic macro for find(1) primaries consistently
MFC after:	3 days
2020-04-18 13:29:54 +00:00
Oleksandr Tymoshenko f2ef15fec4 Fix whiteout support in find(1)
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
2019-01-28 02:00:39 +00:00
Eitan Adler 2da6fd55d9 find(1): remove empty else condition
reported by:	brooks
2018-07-25 03:42:07 +00:00
Eitan Adler 9fe7e0020a find(1): use correct type for readlink 2018-07-01 20:09:56 +00:00
Eitan Adler b422540a99 find(1): deLINTify 2018-07-01 20:09:52 +00:00
Eitan Adler 06668f7f65 find(1): remove portability ifdefs
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.
2018-07-01 19:44:26 +00:00
Alex Richardson c3a6ea5ba6 Allow compiling usr.bin/find on Linux and Mac
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
2018-02-06 15:41:26 +00:00
Jilles Tjoelker 39afde0dcc find: Speed up tests by using touch -d instead of sleep for timestamps
I have verified that the tests still detect the absence of the r327362 fix.
2018-01-04 22:59:24 +00:00
Jilles Tjoelker 9d75d6c9d5 find: Link tests to the build 2017-12-31 19:24:13 +00:00
Conrad Meyer d8a0fe102c find(1): Fix -newer and -samefile to conform to POSIX[0]
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
2017-12-29 22:08:43 +00:00
Eitan Adler c305c18ed1 find(1): remove unused variable 2017-12-13 03:36:33 +00:00
Pedro F. Giffuni 8a16b7a18f General further adoption of SPDX licensing ID tags.
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.
2017-11-20 19:49:47 +00:00
Xin LI 0ab69d713c find(1): Don't treat statfs() error as fatal in f_fstype, which can happen
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
2017-11-11 19:18:47 +00:00
Bryan Drewery ea825d0274 DIRDEPS_BUILD: Update dependencies.
Sponsored by:	Dell EMC Isilon
2017-10-31 00:07:04 +00:00
Warner Losh fbbd9655e5 Renumber copyright clause 4
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
2017-02-28 23:42:47 +00:00
Sevan Janiyan 16ce602c2e Improve wording when describing -mmin.
PR:		215922
Submitted by:	danielsh AT apache DOT org
Approved by:	bcr (mentor)
MFC after:	5 days
Differential Revision:	https://reviews.freebsd.org/D9313
2017-01-24 10:42:21 +00:00
Konstantin Belousov 1c32456953 Use type-independent formats for printing nlink_t and ino_t.
Extracted from:	ino64 work by gleb, mckusick
Discussed with:	mckusick
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2017-01-06 16:59:33 +00:00
Marcelo Araujo 26ac9660a4 Use NULL instead of 0 for pointers.
MFC after:	2 weeks.
2016-04-18 07:05:18 +00:00
Bryan Drewery bd18fd57db DIRDEPS_BUILD: Regenerate without local dependencies.
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
2016-02-24 17:20:11 +00:00
Jilles Tjoelker a2925a5ae3 find: Fix segfault with very long path in -exec/-ok ... {} \;.
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
2015-08-05 21:33:30 +00:00
Simon J. Gerraty 2ef6d5a7b9 new depends 2015-06-16 23:37:19 +00:00
Simon J. Gerraty ccfb965433 Add META_MODE support.
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
2015-06-13 19:20:56 +00:00
Simon J. Gerraty 44d314f704 dirdeps.mk now sets DEP_RELDIR 2015-06-08 23:35:17 +00:00
Simon J. Gerraty 98e0ffaefb Merge sync of head 2015-05-27 01:19:58 +00:00