From c81610f7a33fe17fc6fe4571ecd1cfb458ff4857 Mon Sep 17 00:00:00 2001 From: Jonas 'Sortie' Termansen Date: Fri, 22 May 2015 16:34:47 +0200 Subject: [PATCH] Fix du counting block devices. --- utils/du.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/utils/du.cpp b/utils/du.cpp index 01a966ed..9395f3df 100644 --- a/utils/du.cpp +++ b/utils/du.cpp @@ -197,7 +197,9 @@ bool disk_usage_file_at(int relfd, else if ( flag_same_device && st.st_dev != expected_dev ) return true; - uintmax_t num_bytes = flags & FLAG_APPARENT_SIZE ? + uintmax_t num_bytes = S_ISBLK(st.st_mode) ? + 0 : + flags & FLAG_APPARENT_SIZE ? (uintmax_t) st.st_size : st.st_blocks * 512; @@ -252,7 +254,7 @@ bool disk_usage_file_at(int relfd, *num_bytes_ptr = num_bytes; #if defined(__sortix__) - if ( derror(dir) ) + if ( derror(dir) && errno != ENOTDIR ) { error(0, errno, "reading directory `%s'", path); closedir(dir);