Magellan Linux

Diff of /trunk/mkinitrd-magellan/busybox/archival/bbunzip.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 983 by niro, Fri Apr 24 18:33:46 2009 UTC revision 984 by niro, Sun May 30 11:32:42 2010 UTC
# Line 30  int open_to_or_warn(int to_fd, const cha Line 30  int open_to_or_warn(int to_fd, const cha
30    
31  int FAST_FUNC bbunpack(char **argv,  int FAST_FUNC bbunpack(char **argv,
32   char* (*make_new_name)(char *filename),   char* (*make_new_name)(char *filename),
33   USE_DESKTOP(long long) int (*unpacker)(unpack_info_t *info)   IF_DESKTOP(long long) int (*unpacker)(unpack_info_t *info)
34  )  )
35  {  {
36   struct stat stat_buf;   struct stat stat_buf;
37   USE_DESKTOP(long long) int status;   IF_DESKTOP(long long) int status;
38   char *filename, *new_name;   char *filename, *new_name;
39   smallint exitcode = 0;   smallint exitcode = 0;
40   unpack_info_t info;   unpack_info_t info;
# Line 98  int FAST_FUNC bbunpack(char **argv, Line 98  int FAST_FUNC bbunpack(char **argv,
98   status = unpacker(&info);   status = unpacker(&info);
99   if (status < 0)   if (status < 0)
100   exitcode = 1;   exitcode = 1;
101     xclose(STDOUT_FILENO); /* with error check! */
102    
103   if (filename) {   if (filename) {
104   char *del = new_name;   char *del = new_name;
105   if (status >= 0) {   if (status >= 0) {
106   /* TODO: restore other things? */   /* TODO: restore other things? */
107   if (info.mtime) {   if (info.mtime) {
108   struct utimbuf times;   struct timeval times[2];
109    
110   times.actime = info.mtime;   times[1].tv_sec = times[0].tv_sec = info.mtime;
111   times.modtime = info.mtime;   times[1].tv_usec = times[0].tv_usec = 0;
112   /* Close first.   /* Note: we closed it first.
113   * On some systems calling utime   * On some systems calling utimes
114   * then closing resets the mtime. */   * then closing resets the mtime
115   close(STDOUT_FILENO);   * back to current time. */
116   /* Ignoring errors */   utimes(new_name, times); /* ignoring errors */
  utime(new_name, &times);  
117   }   }
118    
119   /* Delete _compressed_ file */   /* Delete _compressed_ file */
# Line 175  char* make_new_name_bunzip2(char *filena Line 175  char* make_new_name_bunzip2(char *filena
175  }  }
176    
177  static  static
178  USE_DESKTOP(long long) int unpack_bunzip2(unpack_info_t *info UNUSED_PARAM)  IF_DESKTOP(long long) int unpack_bunzip2(unpack_info_t *info UNUSED_PARAM)
179  {  {
180   return unpack_bz2_stream_prime(STDIN_FILENO, STDOUT_FILENO);   return unpack_bz2_stream_prime(STDIN_FILENO, STDOUT_FILENO);
181  }  }
# Line 251  char* make_new_name_gunzip(char *filenam Line 251  char* make_new_name_gunzip(char *filenam
251  }  }
252    
253  static  static
254  USE_DESKTOP(long long) int unpack_gunzip(unpack_info_t *info)  IF_DESKTOP(long long) int unpack_gunzip(unpack_info_t *info)
255  {  {
256   USE_DESKTOP(long long) int status = -1;   IF_DESKTOP(long long) int status = -1;
257    
258   /* do the decompression, and cleanup */   /* do the decompression, and cleanup */
259   if (xread_char(STDIN_FILENO) == 0x1f) {   if (xread_char(STDIN_FILENO) == 0x1f) {
# Line 325  char* make_new_name_unlzma(char *filenam Line 325  char* make_new_name_unlzma(char *filenam
325  }  }
326    
327  static  static
328  USE_DESKTOP(long long) int unpack_unlzma(unpack_info_t *info UNUSED_PARAM)  IF_DESKTOP(long long) int unpack_unlzma(unpack_info_t *info UNUSED_PARAM)
329  {  {
330   return unpack_lzma_stream(STDIN_FILENO, STDOUT_FILENO);   return unpack_lzma_stream(STDIN_FILENO, STDOUT_FILENO);
331  }  }
# Line 360  char* make_new_name_uncompress(char *fil Line 360  char* make_new_name_uncompress(char *fil
360  }  }
361    
362  static  static
363  USE_DESKTOP(long long) int unpack_uncompress(unpack_info_t *info UNUSED_PARAM)  IF_DESKTOP(long long) int unpack_uncompress(unpack_info_t *info UNUSED_PARAM)
364  {  {
365   USE_DESKTOP(long long) int status = -1;   IF_DESKTOP(long long) int status = -1;
366    
367   if ((xread_char(STDIN_FILENO) != 0x1f) || (xread_char(STDIN_FILENO) != 0x9d)) {   if ((xread_char(STDIN_FILENO) != 0x1f) || (xread_char(STDIN_FILENO) != 0x9d)) {
368   bb_error_msg("invalid magic");   bb_error_msg("invalid magic");

Legend:
Removed from v.983  
changed lines
  Added in v.984