sahib / rmlint

Extremely fast tool to remove duplicates and other lint from your filesystem
http://rmlint.rtfd.org
GNU General Public License v3.0
1.86k stars 128 forks source link

rmlint not working with FreeBSD faccessat #476

Closed verb closed 3 years ago

verb commented 3 years ago

I compiled v2.10.1 on FreeBSD 12.2-RELEASE-p3 using the instructions at https://rmlint.readthedocs.io/en/latest/install.html, but rmlint doesn't seem to work:

$ mkdir d && rmlint d
WARNING: Can't open directory or file "d": Invalid argument
ERROR: Not all given paths are valid. Aborting.

It appears to be a problem with FreeBSD's faccessat, because it works if I recompile with HAVE_FACCESSAT=0:

$ mkdir d && ./rmlint d                                                                                                                      

# Empty dir(s):            
    rmdir '/home/lee/src/rmlint/d'                                                                                                           

==> 1 file(s) after investigation, nothing to search through.

The affected version of rmlint is:

$ uname -sr && rmlint --version
FreeBSD 12.2-RELEASE-p3
version 2.10.1 compiled: Jan 30 2021 at [17:20:39] "Ludicrous Lemur" (rev 2a4443d1)
compiled with: -mounts +nonstripped -fiemap +sha512 +bigfiles +intl +replay -xattr -btrfs-support

rmlint was written by Christopher <sahib> Pahl and Daniel <SeeSpotRun> Thomas.
The code at https://github.com/sahib/rmlint is licensed under the terms of the GPLv3.

444 seems related, but I couldn't quite follow the resolution.

verb commented 3 years ago

Hmmm, similar to #444 if I disable AT_SYMLINK_NOFOLLOW it works:

$ git diff
diff --git a/lib/cfg.c b/lib/cfg.c
index 92b02136..e46756e2 100644
--- a/lib/cfg.c
+++ b/lib/cfg.c
@@ -109,7 +109,7 @@ guint rm_cfg_add_path(RmCfg *cfg, bool is_prefd, const char *path) {
     int rc = 0;

 #if HAVE_FACCESSAT
-    rc = faccessat(AT_FDCWD, path, R_OK, AT_EACCESS|AT_SYMLINK_NOFOLLOW);
+    rc = faccessat(AT_FDCWD, path, R_OK, AT_EACCESS);
 #else
     rc = access(path, R_OK);
 #endif
$ mkdir d && ./rmlint d

# Empty dir(s):
    rmdir '/home/lee/src/rmlint/d'

==> 1 file(s) after investigation, nothing to search through.
SeeSpotRun commented 3 years ago

Yes, looks like it was fixed in https://github.com/sahib/rmlint/commit/a726d0cbf839d7a0f35962d67e0f60054d0364f6.

Are you able to compile from develop branch and re-check? I don't have a box running FreeBSD at the moment.

verb commented 3 years ago

Oh! I didn't notice develop branch. Yup, confirmed that this is fixed in develop.

Thanks @SeeSpotRun for the quick response and awesome tool! :+1: