Return the same block number irrespective of what is in /dev

Depending on the mode an on whether mknod works (mount options of
$TMPDIR) different stuff might be in /dev. To make the blocksize in of
the ext2 output format reproducible, ignore the content of /dev.
This commit is contained in:
Johannes 'josch' Schauer 2020-05-02 23:51:58 +02:00
parent af5841269c
commit 08319f6c77
Signed by: josch
GPG key ID: F2CBA5C78FBD83E1

View file

@ -2857,8 +2857,10 @@ sub guess_sources_format {
sub approx_disk_usage {
my $directory = shift;
info "approximating disk usage...";
# to return the same number of blocks irrespective of the chosen mode
# we exclude /dev from being counted
open my $fh, '-|', 'du', '--block-size', '1024',
'--summarize', '--one-file-system',
"--exclude=$directory/dev", '--summarize', '--one-file-system',
$directory // error "failed to fork(): $!";
chomp(
my $du = do { local $/; <$fh> }