Magellan Linux

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

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

revision 815 by niro, Sat Sep 1 22:45:15 2007 UTC revision 816 by niro, Fri Apr 24 18:33:46 2009 UTC
# Line 3  Line 3 
3   * Mini ar implementation for busybox   * Mini ar implementation for busybox
4   *   *
5   * Copyright (C) 2000 by Glenn McGrath   * Copyright (C) 2000 by Glenn McGrath
  * Written by Glenn McGrath <bug1@iinet.net.au> 1 June 2000  
6   *   *
7   * Based in part on BusyBox tar, Debian dpkg-deb and GNU ar.   * Based in part on BusyBox tar, Debian dpkg-deb and GNU ar.
8   *   *
# Line 14  Line 13 
13   * http://www.unix-systems.org/single_unix_specification_v2/xcu/ar.html   * http://www.unix-systems.org/single_unix_specification_v2/xcu/ar.html
14   */   */
15    
16  #include "busybox.h"  #include "libbb.h"
17  #include "unarchive.h"  #include "unarchive.h"
18    
19  static void header_verbose_list_ar(const file_header_t *file_header)  static void FAST_FUNC header_verbose_list_ar(const file_header_t *file_header)
20  {  {
21   const char *mode = bb_mode_string(file_header->mode);   const char *mode = bb_mode_string(file_header->mode);
22   char *mtime;   char *mtime;
# Line 38  static void header_verbose_list_ar(const Line 37  static void header_verbose_list_ar(const
37  #define AR_OPT_CREATE 0x20  #define AR_OPT_CREATE 0x20
38  #define AR_OPT_INSERT 0x40  #define AR_OPT_INSERT 0x40
39    
40    int ar_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
41  int ar_main(int argc, char **argv)  int ar_main(int argc, char **argv)
42  {  {
43     static const char msg_unsupported_err[] ALIGN1 =
44     "archive %s is not supported";
45    
46   archive_handle_t *archive_handle;   archive_handle_t *archive_handle;
47   unsigned opt;   unsigned opt;
  static const char msg_unsupported_err[] =  
  "Archive %s not supported.  Install binutils 'ar'.";  
  char magic[8];  
48    
49   archive_handle = init_handle();   archive_handle = init_handle();
50    
51   /* Prepend '-' to the first argument if required */   /* Prepend '-' to the first argument if required */
52   opt_complementary = "--:p:t:x:-1:?:p--tx:t--px:x--pt";   opt_complementary = "--:p:t:x:-1:p--tx:t--px:x--pt";
53   opt = getopt32(argc, argv, "ptxovcr");   opt = getopt32(argv, "ptxovcr");
54    
55   if (opt & AR_CTX_PRINT) {   if (opt & AR_CTX_PRINT) {
56   archive_handle->action_data = data_extract_to_stdout;   archive_handle->action_data = data_extract_to_stdout;
# Line 62  int ar_main(int argc, char **argv) Line 62  int ar_main(int argc, char **argv)
62   archive_handle->action_data = data_extract_all;   archive_handle->action_data = data_extract_all;
63   }   }
64   if (opt & AR_OPT_PRESERVE_DATE) {   if (opt & AR_OPT_PRESERVE_DATE) {
65   archive_handle->flags |= ARCHIVE_PRESERVE_DATE;   archive_handle->ah_flags |= ARCHIVE_PRESERVE_DATE;
66   }   }
67   if (opt & AR_OPT_VERBOSE) {   if (opt & AR_OPT_VERBOSE) {
68   archive_handle->action_header = header_verbose_list_ar;   archive_handle->action_header = header_verbose_list_ar;
# Line 81  int ar_main(int argc, char **argv) Line 81  int ar_main(int argc, char **argv)
81   llist_add_to(&(archive_handle->accept), argv[optind++]);   llist_add_to(&(archive_handle->accept), argv[optind++]);
82   }   }
83    
84   xread(archive_handle->src_fd, magic, 7);   unpack_ar_archive(archive_handle);
  if (strncmp(magic, "!<arch>", 7) != 0) {  
  bb_error_msg_and_die("invalid ar magic");  
  }  
  archive_handle->offset += 7;  
   
  while (get_header_ar(archive_handle) == EXIT_SUCCESS) /* repeat */;  
85    
86   return EXIT_SUCCESS;   return EXIT_SUCCESS;
87  }  }

Legend:
Removed from v.815  
changed lines
  Added in v.816