From 0c88726f4b59c8e500b2ea84e49a3c1ac09b2736 Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Thu, 8 Jan 2026 09:35:48 +0100 Subject: [PATCH 1/2] =?UTF-8?q?df:=20fix=20O(n=C2=B2)=20performance=20in?= =?UTF-8?q?=20deeply=20nested=20directories=20by=20checking=20is=5Fabsolut?= =?UTF-8?q?e()=20before=20is=5Fsymlink()?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/uu/df/src/df.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/uu/df/src/df.rs b/src/uu/df/src/df.rs index d7746b9150e..e89d8d95c0a 100644 --- a/src/uu/df/src/df.rs +++ b/src/uu/df/src/df.rs @@ -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, From 16b78572179b8365bfa8c7659cba494b0ccf9be9 Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Thu, 8 Jan 2026 14:35:32 +0100 Subject: [PATCH 2/2] add "sysfs" to the spell-checker ignore --- src/uu/df/src/df.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/uu/df/src/df.rs b/src/uu/df/src/df.rs index e89d8d95c0a..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;