| author | Alberto Bertogli
<albertito@blitiri.com.ar> 2026-10-30 18:17:16 UTC |
| committer | Alberto Bertogli
<albertito@blitiri.com.ar> 2026-10-30 18:22:36 UTC |
| parent | 46f4db9664fe5c7fa8606dabb0689003d5979c64 |
| test/onefilesystem.tt | +9 | -1 |
| walk.go | +6 | -0 |
diff --git a/test/onefilesystem.tt b/test/onefilesystem.tt index e5270cc..1739eff 100644 --- a/test/onefilesystem.tt +++ b/test/onefilesystem.tt @@ -11,6 +11,12 @@ Prepare the directories, files and mounts. $ mkdir root/mnt/subdir $ echo ddd > root/mnt/subdir/file4 +Bind mount a single file. It sorts first, so we also check that skipping it +doesn't skip the rest of the directory. + + $ touch root/bindfile + $ mount --bind root/mnt/file3 root/bindfile + Generate with -x: only root device files should get checksums. $ alias summer="$TESTDIR/../summer" @@ -29,12 +35,14 @@ Verify with -x: should see only root device files. Verify without -x: root device files match, mount files are missing. $ summer -v --parallel=1 verify root + "root/bindfile": missing checksum attribute "root/dir/file2": match \(checksum:\w+, mtime:\d+\) (re) "root/file1": match \(checksum:\w+, mtime:\d+\) (re) "root/mnt/file3": missing checksum attribute "root/mnt/subdir/file4": missing checksum attribute - 0s: 2 matched, 0 modified, 2 new, 0 corrupted + 0s: 2 matched, 0 modified, 3 new, 0 corrupted Unmount so the test directory can be gracefully cleaned up. + $ umount root/bindfile $ umount root/mnt diff --git a/walk.go b/walk.go index d41b829..87885f1 100644 --- a/walk.go +++ b/walk.go @@ -53,6 +53,12 @@ func openAndInfo(path string, d fs.DirEntry, err error, rootDev deviceID) (bool, return true, nil, nil, err } + // Individual files can be on a different filesystem too (e.g. bind + // mounts). Skip only the file, the rest of the directory is still valid. + if options.oneFilesystem && rootDev != getDevice(info) { + return false, nil, nil, nil + } + fd, err := os.Open(path) if err != nil { return true, nil, nil, err