Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Give users a hint when their locate database is too small.

5 views
Skip to first unread message

Eitan Adler

unread,
Nov 12, 2012, 10:07:16 PM11/12/12
to
What do people think of this? Maybe /usr/libexec/locate.updatedb is a
better pointer?

commit fb03b777daf2c69bb9612902e38fdb25b256be72
Author: Eitan Adler <li...@eitanadler.com>
Date: Mon Nov 12 22:05:55 2012 -0500

Give users a hint when their locate database is too small.

Reviwed by: ???
Approved by: ???
MFC after: 3 weeks

diff --git a/usr.bin/locate/locate/locate.c b/usr.bin/locate/locate/locate.c
index b0faefb..f0c8c37 100644
--- a/usr.bin/locate/locate/locate.c
+++ b/usr.bin/locate/locate/locate.c
@@ -292,7 +292,7 @@ search_mmap(db, s)
err(1, "`%s'", db);
len = sb.st_size;
if (len < (2*NBG))
- errx(1, "database too small: %s", db);
+ errx(1, "database too small: %s\nTry running
/etc/periodic/weekly/310.locate", db);

if ((p = mmap((caddr_t)0, (size_t)len,
PROT_READ, MAP_SHARED,


--
Eitan Adler
_______________________________________________
freebsd...@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "freebsd-hacke...@freebsd.org"

Lars Engels

unread,
Nov 13, 2012, 3:37:09 AM11/13/12
to
On Mon, Nov 12, 2012 at 10:07:16PM -0500, Eitan Adler wrote:
> What do people think of this? Maybe /usr/libexec/locate.updatedb is a
> better pointer?
>
> commit fb03b777daf2c69bb9612902e38fdb25b256be72
> Author: Eitan Adler <li...@eitanadler.com>
> Date: Mon Nov 12 22:05:55 2012 -0500
>
> Give users a hint when their locate database is too small.
>
> Reviwed by: ???
> Approved by: ???
> MFC after: 3 weeks
>
> diff --git a/usr.bin/locate/locate/locate.c b/usr.bin/locate/locate/locate.c
> index b0faefb..f0c8c37 100644
> --- a/usr.bin/locate/locate/locate.c
> +++ b/usr.bin/locate/locate/locate.c
> @@ -292,7 +292,7 @@ search_mmap(db, s)
> err(1, "`%s'", db);
> len = sb.st_size;
> if (len < (2*NBG))
> - errx(1, "database too small: %s", db);
> + errx(1, "database too small: %s\nTry running
> /etc/periodic/weekly/310.locate", db);
>
> if ((p = mmap((caddr_t)0, (size_t)len,
> PROT_READ, MAP_SHARED,
>

Enlarge your .... database! ;-)

Warren Block

unread,
Nov 13, 2012, 9:33:06 AM11/13/12
to
Don't use the unsure "try", just say
"Run /etc/periodic/weekly/310.locate".

And hope it doesn't get renumbered.

Eitan Adler

unread,
Nov 13, 2012, 10:55:02 AM11/13/12
to
On 13 November 2012 09:33, Warren Block <wbl...@wonkity.com> wrote:
...

Ack to all. Final patch sent for approval:

commit 33ed38e54bf7c7c5f0531afa5501f501e1a67279
Author: Eitan Adler <li...@eitanadler.com>
Date: Mon Nov 12 22:05:55 2012 -0500

Give users a hint when their locate database is too small.

Reviwed by: wblock
Reviewed by: gcooper
Reviwed by: "Lowell Gilbert" <lgf...@be-well.ilk.org>
Approved by: cperciva
MFC after: 3 weeks

diff --git a/usr.bin/locate/locate/locate.c b/usr.bin/locate/locate/locate.c
index b0faefb..95b3fed 100644
--- a/usr.bin/locate/locate/locate.c
+++ b/usr.bin/locate/locate/locate.c
@@ -292,7 +292,7 @@ search_mmap(db, s)
err(1, "`%s'", db);
len = sb.st_size;
if (len < (2*NBG))
- errx(1, "database too small: %s", db);
+ errx(1, "database too small: %s\nRun /usr/libexec/locate.updatedb", db);

if ((p = mmap((caddr_t)0, (size_t)len,
PROT_READ, MAP_SHARED,

--
Eitan Adler

Eitan Adler

unread,
Nov 13, 2012, 10:58:12 AM11/13/12
to
On 13 November 2012 10:55, Eitan Adler <li...@eitanadler.com> wrote:
> On 13 November 2012 09:33, Warren Block <wbl...@wonkity.com> wrote:
> ...
>
> Ack to all. Final patch sent for approval:
>
> commit 33ed38e54bf7c7c5f0531afa5501f501e1a67279
> Author: Eitan Adler <li...@eitanadler.com>
> Date: Mon Nov 12 22:05:55 2012 -0500
>
> Give users a hint when their locate database is too small.
>
> Reviwed by: wblock
> Reviewed by: gcooper
> Reviwed by: "Lowell Gilbert" <lgf...@be-well.ilk.org>

with these typos fixed ;)

Eitan Adler

unread,
Nov 13, 2012, 11:05:17 AM11/13/12
to
On 13 November 2012 10:58, Eitan Adler <li...@eitanadler.com> wrote:

Okay... sorry for the spam. I remember there was a reason I used
/etc/periodic/weekly/310.locate instead of /usr/libexec/locate.updatedb.
The latter must not be run as root, and the former takes care of this work.

Since the default is to enable weekly updates I am inclined to use the
310.locate script instead.

Ian Lepore

unread,
Nov 13, 2012, 11:10:22 AM11/13/12
to
On Tue, 2012-11-13 at 11:05 -0500, Eitan Adler wrote:
> On 13 November 2012 10:58, Eitan Adler <li...@eitanadler.com> wrote:
>
> Okay... sorry for the spam. I remember there was a reason I used
> /etc/periodic/weekly/310.locate instead of /usr/libexec/locate.updatedb.
> The latter must not be run as root, and the former takes care of this work.
>
> Since the default is to enable weekly updates I am inclined to use the
> 310.locate script instead.
>
>
>

Would it work to refer them to the locate.updatedb manpage (which
references the periodic script, and presumably would be kept up to date
with any script renaming/numbering)?

-- Ian

Eitan Adler

unread,
Nov 13, 2012, 11:14:11 AM11/13/12
to
On 13 November 2012 11:10, Ian Lepore <fre...@damnhippie.dyndns.org> wrote:
> Would it work to refer them to the locate.updatedb manpage (which
> references the periodic script, and presumably would be kept up to date
> with any script renaming/numbering)?

If I could avoid the indirection I'd like to avoid it.

"Do this" is more helpful than "See this which tells you what to do."


--
Eitan Adler

Garrett Cooper

unread,
Nov 13, 2012, 11:15:36 AM11/13/12
to
On Nov 13, 2012, at 8:05 AM, Eitan Adler <li...@eitanadler.com> wrote:

> On 13 November 2012 10:58, Eitan Adler <li...@eitanadler.com> wrote:
>
> Okay... sorry for the spam. I remember there was a reason I used
> /etc/periodic/weekly/310.locate instead of /usr/libexec/locate.updatedb.
> The latter must not be run as root, and the former takes care of this work.
>
> Since the default is to enable weekly updates I am inclined to use the
> 310.locate script instead.

Ok. The only thing about hardcoding an
RC script name into a binary is that I felt it was more likely to change whereas locate.updatedb is more constant..
Thanks!
-Garrett

Lowell Gilbert

unread,
Nov 13, 2012, 9:05:46 AM11/13/12
to
Eitan Adler <li...@eitanadler.com> writes:

> What do people think of this? Maybe /usr/libexec/locate.updatedb is a
> better pointer?

Yes, I would think locate.updatedb(8) would be the appropriate
reference, because it's possible to build locate databases in ways and
for reasons other than the weekly script.

I assume that the precise cutoff value is chosen not because the number
of bigrams is important but because the size of the bigram buffer is,
and that it's only notated as (2*NBG) because BGBUFSIZE isn't defined in
a header...

> commit fb03b777daf2c69bb9612902e38fdb25b256be72
> Author: Eitan Adler <li...@eitanadler.com>
> Date: Mon Nov 12 22:05:55 2012 -0500
>
> Give users a hint when their locate database is too small.
>
> Reviwed by: ???
> Approved by: ???
> MFC after: 3 weeks
>
> diff --git a/usr.bin/locate/locate/locate.c b/usr.bin/locate/locate/locate.c
> index b0faefb..f0c8c37 100644
> --- a/usr.bin/locate/locate/locate.c
> +++ b/usr.bin/locate/locate/locate.c
> @@ -292,7 +292,7 @@ search_mmap(db, s)
> err(1, "`%s'", db);
> len = sb.st_size;
> if (len < (2*NBG))
> - errx(1, "database too small: %s", db);
> + errx(1, "database too small: %s\nTry running
> /etc/periodic/weekly/310.locate", db);
>
> if ((p = mmap((caddr_t)0, (size_t)len,
> PROT_READ, MAP_SHARED,

Benjamin Kaduk

unread,
Nov 13, 2012, 11:10:20 PM11/13/12
to
On Tue, 13 Nov 2012, Eitan Adler wrote:

>
> Ack to all. Final patch sent for approval:
>
> diff --git a/usr.bin/locate/locate/locate.c b/usr.bin/locate/locate/locate.c
> index b0faefb..95b3fed 100644
> --- a/usr.bin/locate/locate/locate.c
> +++ b/usr.bin/locate/locate/locate.c
> @@ -292,7 +292,7 @@ search_mmap(db, s)
> err(1, "`%s'", db);
> len = sb.st_size;
> if (len < (2*NBG))
> - errx(1, "database too small: %s", db);
> + errx(1, "database too small: %s\nRun /usr/libexec/locate.updatedb", db);

That looks longer than 80 characters, a limit given implicitly in style.9.

-Ben


>
> if ((p = mmap((caddr_t)0, (size_t)len,
> PROT_READ, MAP_SHARED,
>
> --
> Eitan Adler

Warren Block

unread,
Nov 14, 2012, 11:32:40 AM11/14/12
to
On Tue, 13 Nov 2012, Benjamin Kaduk wrote:
>> if (len < (2*NBG))
>> - errx(1, "database too small: %s", db);
>> + errx(1, "database too small: %s\nRun /usr/libexec/locate.updatedb", db);
>
> That looks longer than 80 characters, a limit given implicitly in style.9.

There's a \n in there.

Eitan Adler

unread,
Nov 14, 2012, 11:35:08 AM11/14/12
to
On 14 November 2012 11:32, Warren Block <wbl...@wonkity.com> wrote:
> On Tue, 13 Nov 2012, Benjamin Kaduk wrote:
>>>
>>> if (len < (2*NBG))
>>> - errx(1, "database too small: %s", db);
>>> + errx(1, "database too small: %s\nRun
>>> /usr/libexec/locate.updatedb", db);
>>
>>
>> That looks longer than 80 characters, a limit given implicitly in style.9.

I think he meant the source line is too long.


--
Eitan Adler

Benjamin Kaduk

unread,
Nov 14, 2012, 4:43:21 PM11/14/12
to
On Wed, 14 Nov 2012, Eitan Adler wrote:

> On 14 November 2012 11:32, Warren Block <wbl...@wonkity.com> wrote:
>> On Tue, 13 Nov 2012, Benjamin Kaduk wrote:
>>>>
>>>> if (len < (2*NBG))
>>>> - errx(1, "database too small: %s", db);
>>>> + errx(1, "database too small: %s\nRun
>>>> /usr/libexec/locate.updatedb", db);
>>>
>>>
>>> That looks longer than 80 characters, a limit given implicitly in style.9.
>
> I think he meant the source line is too long.

Indeed. Apparently alpine wrapped it for my reply; I'm not sure why.

-Ben

Ivan Voras

unread,
Nov 15, 2012, 6:43:55 AM11/15/12
to
On 13/11/2012 04:07, Eitan Adler wrote:
> What do people think of this? Maybe /usr/libexec/locate.updatedb is a
> better pointer?

... or, make it automagical by adding a rc.d script which will test the
database exists (or is "too small") and start locate.updatedb as a
background / detached process?

Orthogonal to that, I'm always surprise by how fast Linux's updatedb is.
I don't know if it is due to file system differences or some fundamental
differences (incremental updates?), but updatedb on Linux usually takes
1-3 seconds, while on FreeBSD it is 10-120 seconds.



> commit fb03b777daf2c69bb9612902e38fdb25b256be72
> Author: Eitan Adler <li...@eitanadler.com>
> Date: Mon Nov 12 22:05:55 2012 -0500
>
> Give users a hint when their locate database is too small.
>
> Reviwed by: ???
> Approved by: ???
> MFC after: 3 weeks
>
> diff --git a/usr.bin/locate/locate/locate.c b/usr.bin/locate/locate/locate.c
> index b0faefb..f0c8c37 100644
> --- a/usr.bin/locate/locate/locate.c
> +++ b/usr.bin/locate/locate/locate.c
> @@ -292,7 +292,7 @@ search_mmap(db, s)
> err(1, "`%s'", db);
> len = sb.st_size;
> if (len < (2*NBG))
> - errx(1, "database too small: %s", db);
> + errx(1, "database too small: %s\nTry running
> /etc/periodic/weekly/310.locate", db);
>
signature.asc
0 new messages