[PATCH] Retain timestamp with gunzip
Denys Vlasenko
vda.linux at googlemail.com
Sat Nov 1 13:16:58 UTC 2008
On Friday 31 October 2008 23:36, Ian Wienand wrote:
> --- archival/bbunzip.c (revision 23853)
> +++ archival/bbunzip.c (working copy)
> @@ -30,13 +30,14 @@
>
> int FAST_FUNC bbunpack(char **argv,
> char* (*make_new_name)(char *filename),
> - USE_DESKTOP(long long) int (*unpacker)(void)
> + USE_DESKTOP(long long) int (*unpacker)(unpack_info_t *info)
> )
> {
> struct stat stat_buf;
> USE_DESKTOP(long long) int status;
> char *filename, *new_name;
> smallint exitcode = 0;
> + unpack_info_t info = { .mtime = 0 };
Wrong. You need to reset it before every unpacker() call.
> + if (info) {
> +#if BB_LITTLE_ENDIAN
> + /* gzip data always in le */
> + header.formatted.mtime =
> + SWAP_LE32(header.formatted.mtime);
> +#endif
> + info->mtime = header.formatted.mtime;
> + }
Won't work correctly on big endian machine.
Correct code seems to be:
if (info)
info->mtime = SWAP_LE32(header.formatted.mtime);
I applied the patch with small fixes. Thanks
--
vda
More information about the busybox
mailing list