X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=src%2Fxheader.c;h=a5452a1be63344d120b62e9f0c958c3755b7ee24;hb=5a9ac8312e2336c854f6bec2d0ae404a3b3bc30d;hp=57ace12adf6f7b28d2234ac8ac4ab8ec85f1169a;hpb=df7b55a8f6354e30e8da62eec7f706df033d0c81;p=chaz%2Ftar diff --git a/src/xheader.c b/src/xheader.c index 57ace12..a5452a1 100644 --- a/src/xheader.c +++ b/src/xheader.c @@ -1,21 +1,22 @@ /* POSIX extended headers for tar. - Copyright (C) 2003, 2004, 2005, 2006, 2007, 2009, 2010, 2012 - Free Software Foundation, Inc. + Copyright (C) 2003-2007, 2009-2010, 2012-2014 Free Software + Foundation, Inc. - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the - Free Software Foundation; either version 3, or (at your option) any later - version. + This file is part of GNU tar. - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General - Public License for more details. + GNU tar is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ + GNU tar is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ #include @@ -754,6 +755,16 @@ xheader_decode (struct tar_stat_info *st) continue; } run_override_list (keyword_override_list, st); + + /* The archived (effective) file size is always set directly in tar header + field, possibly overridden by "size" extended header - in both cases, + result is now decoded in st->stat.st_size */ + st->archive_file_size = st->stat.st_size; + + /* The real file size (given by stat()) may be redefined for sparse + files in "GNU.sparse.realsize" extended header */ + if (st->real_size_set) + st->stat.st_size = st->real_size; } static void @@ -802,11 +813,11 @@ xheader_store (char const *keyword, struct tar_stat_info *st, t = locate_handler (keyword); if (!t || !t->coder) return; - if (xheader_keyword_deleted_p (keyword) - || xheader_keyword_override_p (keyword)) + if (xheader_keyword_deleted_p (keyword)) return; xheader_init (&st->xhdr); - t->coder (st, keyword, &st->xhdr, data); + if (!xheader_keyword_override_p (keyword)) + t->coder (st, keyword, &st->xhdr, data); } void @@ -1016,7 +1027,7 @@ xheader_string_end (struct xheader *xhdr, char const *keyword) } x_obstack_blank (xhdr, p); x_obstack_1grow (xhdr, '\n'); - cp = obstack_next_free (xhdr->stk) - xhdr->string_length - p - 1; + cp = (char*) obstack_next_free (xhdr->stk) - xhdr->string_length - p - 1; memmove (cp + p, cp, xhdr->string_length); cp = stpcpy (cp, np); *cp++ = ' '; @@ -1359,7 +1370,10 @@ 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; + { + st->real_size_set = 1; + st->real_size = u; + } } static void