aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/archive/tar/sparse_unix.go8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/archive/tar/sparse_unix.go b/src/archive/tar/sparse_unix.go
index 76b4c6cc2b..4bc3482858 100644
--- a/src/archive/tar/sparse_unix.go
+++ b/src/archive/tar/sparse_unix.go
@@ -23,8 +23,12 @@ func sparseDetectUnix(f *os.File) (sph sparseHoles, err error) {
const seekHole = 4 // SEEK_HOLE from unistd.h
// Check for seekData/seekHole support.
- if _, err := f.Seek(0, seekHole); errno(err) == syscall.EINVAL {
- return nil, nil // Either old kernel or FS does not support this
+ // Different OS and FS may differ in the exact errno that is returned when
+ // there is no support. Rather than special-casing every possible errno
+ // representing "not supported", just assume that a non-nil error means
+ // that seekData/seekHole is not supported.
+ if _, err := f.Seek(0, seekHole); err != nil {
+ return nil, nil
}
// Populate the SparseHoles.