sparse: list (and --verify) also big sparse files

Resolves: #916995
Version: 1.27.1-3
This commit is contained in:
Pavel Raiskup 2014-04-01 14:12:44 +02:00
parent 6b8c4d7673
commit 777c0d021d
2 changed files with 112 additions and 1 deletions

View File

@ -0,0 +1,102 @@
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

View File

@ -81,6 +81,13 @@ Patch10: tar-1.27.1-default-acls.patch
# ~> #1082608 # ~> #1082608
Patch11: tar-1.27.1-sparse-inf-loops.patch Patch11: tar-1.27.1-sparse-inf-loops.patch
# --posix & big (effective) sparse files can not be listed
# ~> dowstream
# http://www.mail-archive.com/bug-tar%40gnu.org/msg03909.html
# http://www.mail-archive.com/bug-tar@gnu.org/msg04489.html
# ~> #916995
Patch12: tar-1.27.1-big-sparse-listing.patch
# run "make check" by default # run "make check" by default
%bcond_without check %bcond_without check
@ -125,6 +132,7 @@ the rmt package on the remote box.
%patch9 -p1 -b .document-exclude-mistakes %patch9 -p1 -b .document-exclude-mistakes
%patch10 -p1 -b .default-acls %patch10 -p1 -b .default-acls
%patch11 -p1 -b .inf-loops-in-sparse %patch11 -p1 -b .inf-loops-in-sparse
%patch12 -p1 -b .big-sparse
autoreconf -v autoreconf -v
@ -183,10 +191,11 @@ fi
%{_infodir}/tar.info* %{_infodir}/tar.info*
%changelog %changelog
* Mon Mar 31 2014 Pavel Raiskup <praiskup@redhat.com> - 1.27.1-3 * Tue Apr 01 2014 Pavel Raiskup <praiskup@redhat.com> - 1.27.1-3
- document --exclude mistakes (#903666) - document --exclude mistakes (#903666)
- fix default ACLs propagation (#1082603) - fix default ACLs propagation (#1082603)
- infinite loop(s) in sparse-file handling (#1082608) - infinite loop(s) in sparse-file handling (#1082608)
- fix listing (and --verify) for big sparse files (#916995)
* Fri Nov 29 2013 Pavel Raiskup <praiskup@redhat.com> - 1.27.1-2 * Fri Nov 29 2013 Pavel Raiskup <praiskup@redhat.com> - 1.27.1-2
- sync manual page contents with help2man output - sync manual page contents with help2man output