777c0d021d
Resolves: #916995 Version: 1.27.1-3
103 lines
3.5 KiB
Diff
103 lines
3.5 KiB
Diff
diff --git a/src/list.c b/src/list.c
|
|
index 23613f7..ef71b4f 100644
|
|
--- a/src/list.c
|
|
+++ b/src/list.c
|
|
@@ -671,7 +671,6 @@ decode_header (union block *header, struct tar_stat_info *stat_info,
|
|
}
|
|
}
|
|
|
|
- stat_info->archive_file_size = stat_info->stat.st_size;
|
|
xheader_decode (stat_info);
|
|
|
|
if (sparse_member_p (stat_info))
|
|
diff --git a/src/sparse.c b/src/sparse.c
|
|
index 250e845..8e840cf 100644
|
|
--- a/src/sparse.c
|
|
+++ b/src/sparse.c
|
|
@@ -892,7 +892,7 @@ static struct tar_sparse_optab const star_optab = {
|
|
* 1.0
|
|
|
|
Starting from this version, the exact sparse format version is specified
|
|
- explicitely in the header using the following variables:
|
|
+ explicitly in the header using the following variables:
|
|
|
|
GNU.sparse.major Major version
|
|
GNU.sparse.minor Minor version
|
|
@@ -921,7 +921,7 @@ static struct tar_sparse_optab const star_optab = {
|
|
directory. Then, using a simple program it would be possible to expand the
|
|
file to its original form even without GNU tar.
|
|
|
|
- Bu default, v.1.0 archives are created. To use other formats,
|
|
+ By default, v.1.0 archives are created. To use other formats,
|
|
--sparse-version option is provided. Additionally, v.0.0 can be obtained
|
|
by deleting GNU.sparse.map from 0.1 format: --sparse-version 0.1
|
|
--pax-option delete=GNU.sparse.map
|
|
diff --git a/src/tar.h b/src/tar.h
|
|
index 70055af..5f52bd0 100644
|
|
--- a/src/tar.h
|
|
+++ b/src/tar.h
|
|
@@ -327,6 +327,10 @@ struct tar_stat_info
|
|
size_t sparse_map_size; /* Size of the sparse map */
|
|
struct sp_array *sparse_map;
|
|
|
|
+ off_t real_size; /* The real size of sparse file */
|
|
+ int real_size_set; /* True when GNU.sparse.realsize is set in
|
|
+ archived file */
|
|
+
|
|
size_t xattr_map_size; /* Size of the xattr map */
|
|
struct xattr_array *xattr_map;
|
|
|
|
diff --git a/src/xheader.c b/src/xheader.c
|
|
index c8c54b6..ac7ff34 100644
|
|
--- a/src/xheader.c
|
|
+++ b/src/xheader.c
|
|
@@ -741,6 +741,20 @@ decx (void *data, char const *keyword, char const *value, size_t size)
|
|
keyword));
|
|
}
|
|
|
|
+static void
|
|
+xheader_fixup_file_size (struct tar_stat_info *st)
|
|
+{
|
|
+ /* The effective size is in st_size, regardless of whether the file is sparse
|
|
+ * or not. */
|
|
+ st->archive_file_size = st->stat.st_size;
|
|
+
|
|
+ /* For non-sparse files we are done (effective size == real size). But for
|
|
+ sparse files we must take the GNU.sparse.realsize header into account (if
|
|
+ present, its content was parsed by sparse_size_decoder already. */
|
|
+ if (st->real_size_set)
|
|
+ st->stat.st_size = st->real_size;
|
|
+}
|
|
+
|
|
void
|
|
xheader_decode (struct tar_stat_info *st)
|
|
{
|
|
@@ -754,6 +768,11 @@ xheader_decode (struct tar_stat_info *st)
|
|
continue;
|
|
}
|
|
run_override_list (keyword_override_list, st);
|
|
+
|
|
+ /* Here we know for sure that we have "effective" size stored into
|
|
+ st->stat->st_size (this may be set by read_header directly from regular pax
|
|
+ header, or overwritten by size_decoder() from extended pax header). */
|
|
+ xheader_fixup_file_size (st);
|
|
}
|
|
|
|
static void
|
|
@@ -1359,7 +1378,14 @@ sparse_size_decoder (struct tar_stat_info *st,
|
|
{
|
|
uintmax_t u;
|
|
if (decode_num (&u, arg, TYPE_MAXIMUM (off_t), keyword))
|
|
- st->stat.st_size = u;
|
|
+ {
|
|
+ /* do not set the st->stat.st_size here immediately because there may be
|
|
+ the 'size' extended header following 'GNU.sparse.realsize' which would
|
|
+ override our setup. We must handle size (and real size) of sparse
|
|
+ files once whole xheader is read */
|
|
+ st->real_size_set = 1;
|
|
+ st->real_size = u;
|
|
+ }
|
|
}
|
|
|
|
static void
|