diff options
author | kientzle <kientzle@FreeBSD.org> | 2004-10-27 05:15:23 +0000 |
---|---|---|
committer | kientzle <kientzle@FreeBSD.org> | 2004-10-27 05:15:23 +0000 |
commit | 62bf72a32dbb13c7d00f51c145937ad2b2b85397 (patch) | |
tree | bbdef0b504a7c6ad649b245d0398b51f2aff9d97 /lib | |
parent | 2ed479ab984177ace98f09082a340f527fd649f9 (diff) | |
download | FreeBSD-src-62bf72a32dbb13c7d00f51c145937ad2b2b85397.zip FreeBSD-src-62bf72a32dbb13c7d00f51c145937ad2b2b85397.tar.gz |
Allow tar format to read and accept an empty (or non-existent)
file. In particular, this allows bsdtar to append (-r) to
an empty file.
Thanks to: Ryan Sommers
While I'm here, straighten out a misleading comment about GNU-compatible
sparse file handling.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libarchive/archive_read_support_format_tar.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/libarchive/archive_read_support_format_tar.c b/lib/libarchive/archive_read_support_format_tar.c index e8a769c..f273998 100644 --- a/lib/libarchive/archive_read_support_format_tar.c +++ b/lib/libarchive/archive_read_support_format_tar.c @@ -270,7 +270,10 @@ archive_read_format_tar_bid(struct archive *a) bid++; /* Now let's look at the actual header and see if it matches. */ - bytes_read = (a->compression_read_ahead)(a, &h, 512); + if (a->compression_read_ahead != NULL) + bytes_read = (a->compression_read_ahead)(a, &h, 512); + else + bytes_read = 0; /* Empty file. */ if (bytes_read < 0) return (ARCHIVE_FATAL); if (bytes_read == 0 && bid > 0) { @@ -846,8 +849,11 @@ header_common(struct archive *a, struct tar *tar, struct archive_entry *entry, st->st_mode |= S_IFREG; break; case 'S': /* GNU sparse files */ - /* I would like to support these someday... */ - break; + /* + * Sparse files are really just regular files with + * sparse information in the extended area. + */ + /* FALL THROUGH */ default: /* Regular file and non-standard types */ /* * Per POSIX: non-recognized types should always be |