Page MenuHomeFreeBSD

Better help message if locate database does not exists
ClosedPublic

Authored by wosch on Feb 10 2022, 8:01 PM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Jan 2, 10:19 PM
Unknown Object (File)
Dec 2 2024, 11:31 AM
Unknown Object (File)
Nov 25 2024, 7:25 PM
Unknown Object (File)
Nov 24 2024, 11:03 PM
Unknown Object (File)
Nov 18 2024, 4:53 PM
Unknown Object (File)
Oct 25 2024, 6:09 AM
Unknown Object (File)
Sep 25 2024, 3:17 AM
Unknown Object (File)
Sep 25 2024, 1:03 AM
Subscribers

Details

Summary

https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=211501

The current locate error message is misleading.

was:

$ locate foobar
locate: `/var/db/locate.database': No such file or directory

now:
./locate foobar
locate: the locate database '/var/db/locate.database' does not exists.

To create a new database, please run the following command:

  sudo /etc/periodic/weekly/310.locate


was:
$ locate foobar
locate: database too small: /var/db/locate.database
Run /usr/libexec/locate.updatedb

now:
./locate foobar
locate: the locate database '/var/db/locate.database' is less than 256 bytes large.

To create a new database, please run the following command:

  sudo /etc/periodic/weekly/310.locate

Test Plan

sudo rm /var/db/locate.database
./locate foobar

date | sudo tee /var/db/locate.database
./locate foobar

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

wosch requested review of this revision.Feb 10 2022, 8:01 PM

My C is very rusty, so you really want other reviewers than me. I also don't have a VM with -current installed to compile and test this on, but that can be arranged given time, if no one else can.

usr.bin/locate/locate/util.c
280–281

I'd make that "run ... as root" and remove "sudo", since that's not guaranteed to be present and some users will want doas (or even su) instead.

remove "sudo", since that's not guaranteed to be present and some users will want doas (or even su) instead.

@pauamma: good point, I forgot that sudo is not part of the FreeBSD base system.

There is no need to to compile the code on -current, I can do this myself. This review was more about usability and English grammar/typos for the error message. My bad that this was not clear.

@pauamma: good point, I forgot that sudo is not part of the FreeBSD base system.

There is no need to to compile the code on -current, I can do this myself. This review was more about usability and English grammar/typos for the error message. My bad that this was not clear.

With that change, message language and Englishness both LGTM.

This revision is now accepted and ready to land.Feb 13 2022, 12:58 AM