add --skip check/empty

This commit is contained in:
Johannes 'josch' Schauer 2020-05-01 07:39:52 +02:00
parent 1b380e4513
commit 4ea784c1bc
Signed by untrusted user: josch
GPG key ID: F2CBA5C78FBD83E1

View file

@ -3911,9 +3911,12 @@ sub main() {
if (!-d $options->{root}) {
error "$options->{root} exists and is not a directory";
}
# check if the directory is empty or contains nothing more than an
# empty lost+found directory. The latter exists on freshly created
# ext3 and ext4 partitions.
if (any { $_ eq 'check/empty' } @{ $options->{skip} }) {
info "skipping check/empty as requested";
} else {
# check if the directory is empty or contains nothing more than
# an empty lost+found directory. The latter exists on freshly
# created ext3 and ext4 partitions.
# rationale for requiring an empty directory:
# https://bugs.debian.org/833525
opendir(my $dh, $options->{root})
@ -3922,13 +3925,14 @@ sub main() {
# skip the "." and ".." entries
next if $entry eq ".";
next if $entry eq "..";
# if the entry is a directory named "lost+found" then skip it
# if it's empty
if ($entry eq "lost+found" and -d "$options->{root}/$entry") {
# if the entry is a directory named "lost+found" then skip
# it, if it's empty
if ($entry eq "lost+found"
and -d "$options->{root}/$entry") {
opendir(my $dh2, "$options->{root}/$entry");
# Attempt reading the directory thrice. If the third time
# succeeds, then it has more entries than just "." and ".."
# and must thus not be empty.
# Attempt reading the directory thrice. If the third
# time succeeds, then it has more entries than just "."
# and ".." and must thus not be empty.
readdir $dh2;
readdir $dh2;
# rationale for requiring an empty directory:
@ -3943,6 +3947,7 @@ sub main() {
}
}
closedir($dh);
}
} else {
my $num_created = make_path "$options->{root}",
{ error => \my $err };