]> git.sesse.net Git - plocate/commit
Add a native updatedb.
authorSteinar H. Gunderson <steinar+nageru@gunderson.no>
Sat, 21 Nov 2020 17:23:20 +0000 (18:23 +0100)
committerSteinar H. Gunderson <steinar+git@gunderson.no>
Tue, 24 Nov 2020 23:58:09 +0000 (00:58 +0100)
commit63fd24efd774f1ed3f5dab82b934f35b7b039557
tree3590c83be5ef5cadb8803d242f1ff9b9bc783996
parentacce03bb32917e21f2d1d49c5a460d3cd2f72a11
Add a native updatedb.

This incorporates some code from mlocate's updatedb, and thus is compatible
with /etc/updatedb.conf, and supports all the pruning options from it.
All the code has been heavily modified, e.g. the gnulib dependency has been
removed and replaced with STL code (kicking 10k+ lines of code), the bind
mount code has been fixed (it was all broken since the switch from /etc/mtab
to /proc/self/mountinfo) and everything has been reformatted. Like with mlocate,
plocate's updatedb is merging, ie., it can skip readdir() on unchanged
directories. (The logic here is also copied pretty verbatim from mlocate.)
updatedb reads plocate's native format; there's a new max_version 2 that
contains directory timestamps (without it, updatedb will fall back to a full
scan). The timestamps increase the database size by only about 1%, which is a
good tradeoff when we're getting rid of the entire mlocate database.

We liberally use modern features to simplify the implementation; in particular,
openat() to avoid race conditions, instead of mlocate's complicated chdir() dance.
Unfortunately, the combination of the slightly strange storage order from mlocate,
and openat(), means we can need to keep up a bunch of file descriptors open,
but they are not an expensive resource these days, and we try to bump the
limit ourselves if we are allowed to. We also use O_TMPFILE, to make sure we
never leave a half-finished file lying around (mlocate's updatedb tries to
catch signals instead). All of this may hinder portability, so we might ease up
on the requirements later. We don't use io_uring for updatedb at this point.

plocate-build does not write the needed timestamps, so the first upgrade from
mlocate to native plocate requires a full rescan.

NOTE: The format is _not_ frozen yet, and won't be until actual release.
16 files changed:
README
bind-mount.cpp [new file with mode: 0644]
bind-mount.h [new file with mode: 0644]
complete_pread.cpp
complete_pread.h
conf.cpp [new file with mode: 0644]
conf.h [new file with mode: 0644]
database-builder.cpp
database-builder.h
db.h
lib.cpp [new file with mode: 0644]
lib.h [new file with mode: 0644]
meson.build
plocate-build.cpp
plocate.cpp
updatedb.cpp [new file with mode: 0644]