From: Steinar H. Gunderson Date: Sat, 21 Nov 2020 17:23:20 +0000 (+0100) Subject: Add a native updatedb. X-Git-Tag: 1.1.0~19 X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=63fd24efd774f1ed3f5dab82b934f35b7b039557;hp=63fd24efd774f1ed3f5dab82b934f35b7b039557;p=plocate 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. ---