/* 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 <http://www.gnu.org/licenses/>. */
#include <system.h>
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
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
}
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++ = ' ';
{
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