Setting the record straight on SunOS 4.0 'fastfind'
James A. Woods
jaw at eos.arc.nasa.gov
Fri Dec 30 06:34:11 AEST 1988
Under BSD 4.3 Unix, "find filename" is short for
find / -name '*filename*' -print
(by far the most common usage of "find"), except that it runs in seconds
rather than minutes. It is documented in the manual page.
I wrote this code years ago; it was actually part of BSD 4.2, but got lost
in the shuffle at Sun when they went the SVID route. Though undocumented
in the manual page, it half-way works under SunOS 4.0, after first
installing a nightly call to 'updatedb' from crontab. Unfortunately, as
distributed, the compressed filename database is not portable across
architectures because of bit-order problems with calls to putw()/getw().
[In the days of the DEC PDP, these word writes permitted the code to work
on both DEC architectures-- NFS, with disparate machines reading one
database, didn't yet exist.]
However, the Sun 4 / Sun 3 'fastfind' problem is easily fixed by replacing
the reference to
c = getw(fp)
in find.c with something like:
c = getc (fp);
c = ((unsigned char) c << 8) | getc(fp);
plus a similar change to putw() in code.c.
As to the syntax issues, it could be argued that filename matching "glob
style" should be like 'egrep' rather than 'sh' -- this takes somewhat more
work.
Another area for improvement is database build time, now slow partly due
to the use of 'awk'. Finally, the largest crime committed in my design of
five-year old ffind is that it is not "eight-bit clean" for international
character sets. I may remedy this someday (at the slight expense of
compression efficiency), and donate the resulting code to the GNU project,
unless someone has already done such.
James A. Woods (ames!jaw)
NASA Ames Research Center
[[ My thanks to other readers who have also pointed out my gaffe. Good to
see that everyone is still on their toes! --wnl ]]
More information about the Comp.sys.sun
mailing list