Add bounded concurrent scanner

Single-writer controller with a select loop that offers jobs and accepts
results simultaneously, so bounded channels cannot deadlock. statx/fstatat
relative to the directory fd on Linux/macOS, portable fallback elsewhere.
Hard links counted once, symlink loops detected, virtual filesystems
skipped, errors classified and surfaced.
This commit is contained in:
Andy Dixon
2026-10-02 08:02:32 +01:00
parent 61fd9bf711
commit 8233ddcfba
9 changed files with 1260 additions and 0 deletions
+31
View File
@@ -0,0 +1,31 @@
//go:build !linux && !darwin && !freebsd
package platform
import "os"
// ReadDir streams the entries of a directory using the portable os API.
// Allocated size, inode identity and link counts are not available here.
func ReadDir(path string, chunk int, fn ChunkFunc) error {
return readDirGeneric(path, chunk, fn, func(p string) (Meta, error) { return statPath(p, false) })
}
func statPath(path string, follow bool) (Meta, error) {
var fi os.FileInfo
var err error
if follow {
fi, err = os.Stat(path)
} else {
fi, err = os.Lstat(path)
}
if err != nil {
return Meta{}, err
}
m := fromFileInfo(fi)
m.Name = baseName(path)
fillSys(&m, fi)
return m, nil
}
// IsVirtualFS is Linux-specific; elsewhere nothing is skipped.
func IsVirtualFS(string) bool { return false }