GNU bug report logs - #61884
add an option to du that allows to control which file types are counted

Previous Next

Package: coreutils;

Reported by: Christoph Anton Mitterer <calestyo <at> scientia.org>

Date: Wed, 1 Mar 2023 03:20:02 UTC

Severity: normal

Done: Paul Eggert <eggert <at> cs.ucla.edu>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Pádraig Brady <P <at> draigBrady.com>
To: 61884 <at> debbugs.gnu.org, eggert <at> cs.ucla.edu, calestyo <at> scientia.org
Subject: bug#61884: add an option to du that allows to control which file types are counted
Date: Mon, 13 Mar 2023 15:26:14 +0000
[Message part 1 (text/plain, inline)]
On 05/03/2023 01:00, Paul Eggert wrote:
> On 2023-03-04 15:33, Christoph Anton Mitterer wrote:
> 
>> But would symlinks (i.e. their length) count for it?
> 
> Sure, because you can read symlinks by using readlink, and that gives
> you their lengths.
> 
> Come to think of it, POSIX specifies st_size only for regular files and
> symlinks among the files you'll find in a directory. So du --apparent
> should count st_size only for these file types; it should ignore st_size
> for other file types unless we know somehow that those sizes make sense
> (which for directories is problematic for the reasons you mention).
> 
> 
>> What about hardlinked files, would they count once or n times?
> 
> That's an independent axis and is handled by -l. Hard links are not a
> file type.
> 
> 
>>                 b      block (buffered) special
>>                 c      character (unbuffered) special
>>                 d      directory
>>                 p      named pipe (FIFO)
>>                 f      regular file
>>                 l      symbolic link
>>                 s      socket
>>                 D      door (Solaris)
> 
> I expect Coreutils's already-existing usable_st_function should tell us
> which types have usable st_size. This will exclude directories, which
> should be the right thing for your use case.
> 
> 
> So I installed the attached patch to fix du --apparent to count sizes
> only when st_size is well-defined. This should address your use case so
> I'm boldly closing the bug report.

The attached adjusts the du/threshold test to pass
by avoiding testing --apparent with dirs

cheers,
Pádraig
[du--app-dir-test.patch (text/x-patch, attachment)]

This bug report was last modified 2 years and 125 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.