GNU bug report logs - #33757
27.0.50; dired-du-mode displays incorrect human readable file sizes for non-GNU systems

Previous Next

Package: emacs;

Reported by: Matthew Newton <matt <at> mnewton.com>

Date: Sat, 15 Dec 2018 07:35:01 UTC

Severity: minor

Found in version 27.0.50

To reply to this bug, email your comments to 33757 AT debbugs.gnu.org.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#33757; Package emacs. (Sat, 15 Dec 2018 07:35:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Matthew Newton <matt <at> mnewton.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sat, 15 Dec 2018 07:35:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Matthew Newton <matt <at> mnewton.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 27.0.50; dired-du-mode displays incorrect human readable file sizes
 for non-GNU systems
Date: Fri, 14 Dec 2018 22:37:33 -0800
* Reproduction
1. Run MacOS (Or I suspect any OS that is not GNU-based).
2. emacs -Q
3. M-x package-install RET dired-du RET
4. M-x dired RET ~ RET
5. M-x dired-du-mode RET
6. Notice that file sizes are displayed in kbytes, not bytes (they are displayed in bytes in a GNU-based system)
7. M-x dired-du--toggle-human-readable RET
8. M-x z z (to enable file sizes displated in human readable form, i.e. sizes ending in k, M, G, T)
9. File sizes displayed are one order of magnitude smaller than their actual size (e.g. if the file size is 2MB then it will be displayed as 2kB)

* Discussion
The problem seems to arise when the custom variable dired-du-used-space-program is set. For a GNU-based system, it gets set to "du -sb" but for MacOS it gets set to "du -sk". Then later when the human readable sizes are calculated, this difference does not appear to be accounted for.

Why do we make the distinction between a GNU-based system and anything else? Can we just change the logic setting dired-du-used-space-program to always run "du -sb”?


Cheers,
Matt

P.S. This is my first Emacs bug report so please help me out if I should report it differently.



Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#33757; Package emacs. (Sat, 15 Dec 2018 09:53:01 GMT) Full text and rfc822 format available.

Message #8 received at 33757 <at> debbugs.gnu.org (full text, mbox):

From: Robert Pluim <rpluim <at> gmail.com>
To: Matthew Newton <matt <at> mnewton.com>
Cc: 33757 <at> debbugs.gnu.org
Subject: Re: bug#33757: 27.0.50;
 dired-du-mode displays incorrect human readable file sizes for
 non-GNU systems
Date: Sat, 15 Dec 2018 10:52:31 +0100
Matthew Newton <matt <at> mnewton.com> writes:

> * Reproduction
> 1. Run MacOS (Or I suspect any OS that is not GNU-based).
> 2. emacs -Q
> 3. M-x package-install RET dired-du RET
> 4. M-x dired RET ~ RET
> 5. M-x dired-du-mode RET
> 6. Notice that file sizes are displayed in kbytes, not bytes (they are displayed in bytes in a GNU-based system)
> 7. M-x dired-du--toggle-human-readable RET
> 8. M-x z z (to enable file sizes displated in human readable form, i.e. sizes ending in k, M, G, T)
> 9. File sizes displayed are one order of magnitude smaller than their
> actual size (e.g. if the file size is 2MB then it will be displayed as
> 2kB)
>
> * Discussion
> The problem seems to arise when the custom variable
> dired-du-used-space-program is set. For a GNU-based system, it gets
> set to "du -sb" but for MacOS it gets set to "du -sk". Then later when
> the human readable sizes are calculated, this difference does not
> appear to be accounted for.
>
> Why do we make the distinction between a GNU-based system and anything
> else? Can we just change the logic setting dired-du-used-space-program
> to always run "du -sb”?
>

$ uname -a
Darwin rpluim-mac 18.2.0 Darwin Kernel Version 18.2.0: Fri Oct  5 19:41:49 PDT 2018; root:xnu-4903.221.2~2/RELEASE_X86_64 x86_64
$ du -sb
du: illegal option -- b
usage: du [-H | -L | -P] [-a | -s | -d depth] [-c] [-h | -k | -m | -g]
[-x] [-I mask] [file ...]

IOW the fix will have to be in dired-du.

Robert




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#33757; Package emacs. (Sat, 15 Dec 2018 18:14:01 GMT) Full text and rfc822 format available.

Message #11 received at 33757 <at> debbugs.gnu.org (full text, mbox):

From: Matthew Newton <matt <at> mnewton.com>
To: Robert Pluim <rpluim <at> gmail.com>
Cc: 33757 <at> debbugs.gnu.org
Subject: Re: bug#33757: 27.0.50; dired-du-mode displays incorrect human
 readable file sizes for non-GNU systems
Date: Sat, 15 Dec 2018 10:13:33 -0800
Hmm, right you are. I forgot that I had GNU core utils installed on my Mac.

I suggest two things:
1. Look for gdu in path and use that if possible.
2. Add something like `dired-du-used-space-units` to indicate whether file sizes are stored in bytes, kilobytes, whatever. Then modify `dired-du-count-sizes` to multiply appropriately.

I can submit a patch if you think that’s the way to go.

By the way, I just want to verify: Is this the right place to submit a bug report for dired-du?



This bug report was last modified 6 years and 185 days ago.

Previous Next


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