History log of /freebsd-current/usr.bin/whereis/whereis.c
Revision Date Author Comments
# 1d386b48 16-Aug-2023 Warner Losh <imp@FreeBSD.org>

Remove $FreeBSD$: one-line .c pattern

Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/


# 4d846d26 10-May-2023 Warner Losh <imp@FreeBSD.org>

spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD

The SPDX folks have obsoleted the BSD-2-Clause-FreeBSD identifier. Catch
up to that fact and revert to their recommended match of BSD-2-Clause.

Discussed with: pfg
MFC After: 3 days
Sponsored by: Netflix


# c454c571 04-Feb-2022 Stefan Eßer <se@FreeBSD.org>

whereis: fix fetching of user.cs_path sysctl variable

The current implementation of sysctlbyname() does not support the user
sub-tree. This function exits with a return value of 0, but sets the
passed string buffer to an empty string.

As a result, the whereis program did not use the value of the sysctl
variable "user.cs_path", but only the value of the environment
variable "PATH".

This update makes whereis use the sysctl function with a fixed OID,
which already supports the user sub-tree.

MFC after: 3 days


# f5ce1402 24-Jan-2019 Stefan Eßer <se@FreeBSD.org>

Silence Clang Scan warnings regarding the use of strcp().

While these warnings are false positives, the use of strdup() instead of
malloc() and strcpy() simplifies and clarifies the code.

While checking the remaining uses of strcpy and strcat I noticed an
assignment of a strlen() to a variable "s", whose value needs to be
preserved for use in later output routines (where it is used to allocate
a buffer). I do not think that the value of "s" will come out lower than
its correct value and thus there is no risk of a buffer overflow, in the
general case, but a specially crafter argument might lead to an overflow.

The bogus assignment to "s" is removed since this value was only used a
single time in the following malloc() call, which has been removed.

MFC after: 2 weeks


# 1de7b4b8 27-Nov-2017 Pedro F. Giffuni <pfg@FreeBSD.org>

various: general adoption of SPDX licensing ID tags.

Mainly focus on files that use BSD 2-Clause license, however the tool I
was using misidentified many licenses so this was mostly a manual - error
prone - task.

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.

No functional change intended.


# af7ca7c8 01-May-2016 Pedro F. Giffuni <pfg@FreeBSD.org>

usr.bin: minor spelling fixes on comments.

No functional change.


# c1eac826 20-Apr-2016 Baptiste Daroussin <bapt@FreeBSD.org>

Fix bad checking of the return of realloc(3)

Reported by: Coverity
CID: 1007335
MFC after: 3 days


# d919e0d5 18-Apr-2016 Marcelo Araujo <araujo@FreeBSD.org>

Use NULL instead of 0 for pointers.

realloc will return NULL if it cannot allocate memory.

MFC after: 2 weeks.


# 11d9aa67 11-Feb-2015 Colin Percival <cperciva@FreeBSD.org>

Step 1 of eliminating the "games" distribution: Move binaries to /usr/bin;
update paths; and include everything in the "base" distribution.

The "games" distribution being optional made sense when there were more
games and we had small disks; but the "games-like" games were moved into
the ports tree a dozen years ago and the remaining "utility-like" games
occupy less than 0.001% of my laptop's small hard drive. Meanwhile every
new user is confronted by the question "do you want games installed" when
they they try to install FreeBSD.

The next steps will be:

2. Removing punch card (bcd, ppt), phase-of-moon (pom), clock (grdc), and
caesar cipher (caesar, rot13) utilities. I intend to keep fortune, factor,
morse, number, primes, and random, since there is evidence that those are
still being used.

3. Merging src/games into src/usr.bin.

This change will not be MFCed.

Reviewed by: jmg
Discussed at: EuroBSDCon
Approved by: gjb (release-affecting changes)


# fb2ad9d3 30-Dec-2011 Ulrich Spörlein <uqs@FreeBSD.org>

Reencode files from latin1 to UTF-8.

This makes a tiny percentage of entries in calendars ugly for latin1
users, but fixes them for UTF-8 users.

This badly needs a solution involving locale-dependent re-encoding.


# 558b00f5 06-Nov-2011 Ed Schouten <ed@FreeBSD.org>

Mark global functions and/or variables in whereis(1) static where possible.

This allows compilers and static analyzers to more thorough analysis.


# a7d5f7eb 19-Oct-2010 Jamie Gritton <jamie@FreeBSD.org>

A new jail(8) with a configuration file, to replace the work currently done
by /etc/rc.d/jail.


# fe0506d7 09-Mar-2010 Marcel Moolenaar <marcel@FreeBSD.org>

Create the altix project branch. The altix project will add support
for the SGI Altix 350 to FreeBSD/ia64. The hardware used for porting
is a two-module system, consisting of a base compute module and a
CPU expansion module. SGI's NUMAFlex architecture can be an excellent
platform to test CPU affinity and NUMA-aware features in FreeBSD.


# d7f03759 19-Oct-2008 Ulf Lilleengen <lulf@FreeBSD.org>

- Import the HEAD csup code which is the basis for the cvsmode work.


# 2b7b4962 20-Jun-2008 Joerg Wunsch <joerg@FreeBSD.org>

Make the search for sources in PATH_PORTS more accurate. I only
noticed that a "whereis -qs qemu" matched the distfiles subdir of qemu
rather than /usr/ports/emulators/qemu.

It now ignores all dot entries in /usr/ports, plus all entries
starting with a capital letter (maintenance stuff like Templates, but
also includes subdir CVS), plus /usr/ports/distfiles which is simply a
magic name in that respect.


# 6c97c3d1 09-Apr-2005 Stefan Farfeleder <stefanf@FreeBSD.org>

Remove unused variables.


# 48baa772 10-Feb-2005 Ruslan Ermilov <ru@FreeBSD.org>

Fixed usage().


# 4ff23965 15-Jul-2004 Tim J. Robbins <tjr@FreeBSD.org>

Respect locale settings from the environment.


# 1f05bc6c 21-Aug-2002 Johan Karlsson <johan@FreeBSD.org>

Add the -a option to report all matches instead of only the
first of each requested type.

Approved by: joerg, sheldonh (mentor)


# ad23c583 18-Aug-2002 Johan Karlsson <johan@FreeBSD.org>

Correctly handle empty path arguments, e.g., whereis -S -f biff.

Approved by: joerg, sheldonh (mentor)


# 103d6646 25-Jul-2002 Johan Karlsson <johan@FreeBSD.org>

Define all paths in pathnames.h

Approved by: joerg, sheldonh (mentor)


# 8e4c33e9 24-Jul-2002 Johan Karlsson <johan@FreeBSD.org>

Teach whereis(1) about games.

Approved by: joerg, sheldonh (mentor)


# e97f67f5 11-Jul-2002 Joerg Wunsch <joerg@FreeBSD.org>

Complete rewrite, once again.

This is basically a ``C compilation'' of the former whereis.pl file,
employing the same algorithms, and aiming at being mostly
UI-compatible to the old (legally tainted) 4.3BSD whereis(1). In
comparision, the 4.4BSD-Lite version is just another variant of
which(1) only, where in particular the option to search for source
directories is sorely missing.

While i was at it, i added two more options which i contemplated doing
long since. -x will suppress the run of locate(1) to find sources
that could not be found otherwise, potentially saving a lot of time
(but obviously, risking to not find some sources that are well hidden
in the tree). -q will omit the leading name of the query, so in
particular, you can now do something like:

cd `whereis -qs ls`

I'd explicitly like to thank johan for his review which was quite a
bit more than an average review, including sending me a lot of diffs.

Reviewed by: johan


# b68725e3 03-Jul-2002 Johan Karlsson <johan@FreeBSD.org>

Restore copyright and RCSID.
Remove duplicate $FreeBSD$, $NetBSD$.

Submitted by: mike
Approved by: sheldonh (mentor)


# 8d430958 03-Jul-2002 Johan Karlsson <johan@FreeBSD.org>

compact synopsis
s/program [program ...]/program .../
s/program [...]/program .../

Approved by: sheldonh (mentor)


# 058e1851 03-Jul-2002 Johan Karlsson <johan@FreeBSD.org>

Remove -p flag.
OpenBSD's implementation lacks -p, and we don't want to
support the option now, only to lose it if/when we later
switch to OpenBSD's implementation.
This functionality is provided by which(1).

Approved by: sheldonh (mentor)


# 9d1b456e 03-Jul-2002 Johan Karlsson <johan@FreeBSD.org>

Add __FBSDID.
Remove __COPYRIGHT, __RCSID which caused an assembler warning.

Approved by: sheldonh (mentor)


# b78dcb87 03-Jul-2002 Johan Karlsson <johan@FreeBSD.org>

Change to NetBSDs version of whereis.

Approved by: sheldonh (mentor)
Obtained from: NetBSD


# 91ff3f77 03-Jul-2002 Johan Karlsson <johan@FreeBSD.org>

Vendor import of NetBSDs whereis.{c,1}

Approved by: sheldonh (mentor)
Obtained from: NetBSD


# c44252b6 06-Jul-1997 Bruce Evans <bde@FreeBSD.org>

Finish importing Lite2's src/usr.bin, except for ex, diff, grep, mail,
pascal and vmstat.sparc. All changed files on the vendor branch should
already have been imported.


# 1ace9012 14-Jun-1996 Joerg Wunsch <joerg@FreeBSD.org>

A totally revamped whereis(1), bringing back all the functionality of
the 4.3BSD command. Rewritten from scratch after the old man page,
taking account for the different situation with man pages and source
tree hierarchy (re: /usr/src/gnu) of the FreeBSD project.

Reviewed by: wosch (actually loooong time ago)


# 9b50d902 26-May-1994 Rodney W. Grimes <rgrimes@FreeBSD.org>

BSD 4.4 Lite Usr.bin Sources