diff --git a/src/uu/df/src/df.rs b/src/uu/df/src/df.rs index d7746b9150e..ff72dce34a3 100644 --- a/src/uu/df/src/df.rs +++ b/src/uu/df/src/df.rs @@ -2,7 +2,7 @@ // // For the full copyright and license information, please view the LICENSE // file that was distributed with this source code. -// spell-checker:ignore itotal iused iavail ipcent pcent tmpfs squashfs lofs +// spell-checker:ignore itotal iused iavail ipcent pcent tmpfs squashfs lofs sysfs mod blocks; mod columns; mod filesystem; @@ -311,7 +311,11 @@ fn get_all_filesystems(opt: &Options) -> UResult> { // but `vmi` is probably not very long in practice. if is_included(&mi, opt) && is_best(&mounts, &mi) { let dev_path: &Path = Path::new(&mi.dev_name); - if dev_path.is_symlink() { + // Only check is_symlink() for absolute paths. For non-absolute paths + // like "tmpfs", "sysfs", etc., is_symlink() would resolve relative to + // the current working directory, which is extremely slow in deeply + // nested directories (O(n) syscalls where n is the directory depth). + if dev_path.is_absolute() && dev_path.is_symlink() { if let Ok(canonicalized_symlink) = uucore::fs::canonicalize( dev_path, uucore::fs::MissingHandling::Existing,