use List::Util qw(shuffle);
my $tar = $ENV{TAR};
+my @tar_c_flags;
+
+# By default, bsdtar archives sparse files in GNU tar's --format=posix --sparse
+# format, so pg_waldump can't find files that ZFS has decided to store with
+# holes. Turn that off.
+if (system("$tar --no-read-sparse -c - /dev/null > /dev/null") == 0)
+{
+ push(@tar_c_flags, "--no-read-sparse");
+}
program_help_ok('pg_waldump');
program_version_ok('pg_waldump');
# move into the WAL directory before archiving files
my $cwd = getcwd;
chdir($directory) || die "chdir: $!";
- command_ok([$tar, $compression_flags, $archive, @files]);
+ command_ok([$tar, @tar_c_flags, $compression_flags, $archive, @files]);
chdir($cwd) || die "chdir: $!";
}