On Thursday 30 October 2008 00:43, Ian Wienand wrote:
> It would be nice to keep the timestamp from gunzipped files.
> 
> The proposed patch adds an 'mtime' argument for unpackers to fill out,
> which gets stamped in via utime.  I imagine the other unpackers can
> use it if they care, and it could be expanded to a struct of other
> useful information if it was ever required.

Good idea.

Please do make it a struct (one-member for now) so that
we don't need to re-shuffle this stuff *again*.
Let's call it "struct unpack_misc_info"?

> -USE_DESKTOP(long long) int unpack_bunzip2(void)
> +USE_DESKTOP(long long) int unpack_bunzip2(time_t *mtime)
>  {
> +     *mtime = 0; // not handled yet

Don't do it. Assume that it is suitably initialized
(say, memset to 0) and only fill in values if they differ
from that.

>       return unpack_bz2_stream_prime(STDIN_FILENO, STDOUT_FILENO);
>  }
>  
> @@ -235,7 +248,7 @@
>  }
>  
>  static
> -USE_DESKTOP(long long) int unpack_gunzip(void)
> +USE_DESKTOP(long long) int unpack_gunzip(time_t *mtime)
>  {
>       USE_DESKTOP(long long) int status = -1;
>  
> @@ -245,9 +258,10 @@
>  
>               magic2 = xread_char(STDIN_FILENO);
>               if (ENABLE_FEATURE_SEAMLESS_Z && magic2 == 0x9d) {
> +                     mtime = NULL;

Why do you set mtime = NULL?


>  static
> -USE_DESKTOP(long long) int unpack_unlzma(void)
> +USE_DESKTOP(long long) int unpack_unlzma(time_t *mtime)
>  {
> +     *mtime = 0;

See above

>       return unpack_lzma_stream(STDIN_FILENO, STDOUT_FILENO);
>  }





> -static int check_header_gzip(STATE_PARAM_ONLY)
> +static int check_header_gzip(STATE_PARAM time_t *mtime)
>  {
>       union {
>               unsigned char raw[8];
>               struct {
>                       uint8_t gz_method;
>                       uint8_t flags;
> -                     //uint32_t mtime; - unused fields
> -                     //uint8_t xtra_flags;
> -                     //uint8_t os_flags;
> -             } formatted; /* packed */
> +                     uint32_t mtime;
> +                     uint8_t xtra_flags;
> +                     uint8_t os_flags;
> +             } __attribute__((packed)) formatted;
>       } header;

Why did you uncomment the other two?

--
vda
_______________________________________________
busybox mailing list
[email protected]
http://busybox.net/cgi-bin/mailman/listinfo/busybox

Reply via email to