English Language flag
// Log In
// CVSweb
Project: FreeWRT
// Summary // Activity // Search // Tracker // Lists // News // SCM // Wiki

SCM Repository

ViewVC logotype

Diff of /branches/freewrt_1_0/tools/paxmirabilis/src/ar_io.c

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

revision 2714 by wbx, Thu Sep 28 10:42:55 2006 UTC revision 2715 by tg, Tue Jun 5 14:52:44 2007 UTC
# Line 1  Line 1 
1  /**     $MirOS: src/bin/pax/ar_io.c,v 1.6 2006/06/23 23:03:55 tg Exp $ */  /**     $MirOS: src/bin/pax/ar_io.c,v 1.8 2007/02/17 04:52:39 tg Exp $ */
2  /*      $OpenBSD: ar_io.c,v 1.37 2005/08/04 10:02:44 mpf Exp $  */  /*      $OpenBSD: ar_io.c,v 1.37 2005/08/04 10:02:44 mpf Exp $  */
3  /*      $NetBSD: ar_io.c,v 1.5 1996/03/26 23:54:13 mrg Exp $    */  /*      $NetBSD: ar_io.c,v 1.5 1996/03/26 23:54:13 mrg Exp $    */
4    
# Line 35  Line 35 
35   * SUCH DAMAGE.   * SUCH DAMAGE.
36   */   */
37    
38  #include <sys/types.h>  #include <sys/param.h>
39  #include <sys/time.h>  #include <sys/time.h>
40  #include <sys/stat.h>  #include <sys/stat.h>
41  #include <sys/ioctl.h>  #include <sys/ioctl.h>
42  #ifndef __INTERIX  #ifndef __INTERIX
43  #include <sys/mtio.h>  #include <sys/mtio.h>
44  #endif  #endif
 #include <sys/param.h>  
45  #include <sys/wait.h>  #include <sys/wait.h>
46  #include <signal.h>  #include <signal.h>
47  #include <string.h>  #include <string.h>
# Line 57  Line 56 
56  #include "extern.h"  #include "extern.h"
57    
58  __SCCSID("@(#)ar_io.c   8.2 (Berkeley) 4/18/94");  __SCCSID("@(#)ar_io.c   8.2 (Berkeley) 4/18/94");
59  __RCSID("$MirOS: src/bin/pax/ar_io.c,v 1.6 2006/06/23 23:03:55 tg Exp $");  __RCSID("$MirOS: src/bin/pax/ar_io.c,v 1.8 2007/02/17 04:52:39 tg Exp $");
60    
61  /*  /*
62   * Routines which deal directly with the archive I/O device/file.   * Routines which deal directly with the archive I/O device/file.
# Line 81  static int invld_rec;                  /* tape has out Line 80  static int invld_rec;                  /* tape has out
80  static int wr_trail = 1;                /* trailer was rewritten in append */  static int wr_trail = 1;                /* trailer was rewritten in append */
81  static int can_unlnk = 0;               /* do we unlink null archives?  */  static int can_unlnk = 0;               /* do we unlink null archives?  */
82  const char *arcname;                    /* printable name of archive */  const char *arcname;                    /* printable name of archive */
83    static char *arcname_;                  /* this is so we can free(3) it */
84  const char *gzip_program;               /* name of gzip program */  const char *gzip_program;               /* name of gzip program */
85  static pid_t zpid = -1;                 /* pid of child process */  static pid_t zpid = -1;                 /* pid of child process */
86  int force_one_volume;                   /* 1 if we ignore volume changes */  int force_one_volume;                   /* 1 if we ignore volume changes */
87    
88    #ifndef __INTERIX
89  static int get_phys(void);  static int get_phys(void);
90    #endif
91  extern sigset_t s_mask;  extern sigset_t s_mask;
92  static void ar_start_gzip(int, const char *, int);  static void ar_start_gzip(int, int);
93    
94  /*  /*
95   * ar_open()   * ar_open()
# Line 124  ar_open(const char *name) Line 126  ar_open(const char *name)
126                  } else if ((arfd = open(name, EXT_MODE, DMOD)) < 0)                  } else if ((arfd = open(name, EXT_MODE, DMOD)) < 0)
127                          syswarn(1, errno, "Failed open to read on %s", name);                          syswarn(1, errno, "Failed open to read on %s", name);
128                  if (arfd != -1 && gzip_program != NULL)                  if (arfd != -1 && gzip_program != NULL)
129                          ar_start_gzip(arfd, gzip_program, 0);                          ar_start_gzip(arfd, 0);
130                  break;                  break;
131          case ARCHIVE:          case ARCHIVE:
132                  if (name == NULL) {                  if (name == NULL) {
# Line 135  ar_open(const char *name) Line 137  ar_open(const char *name)
137                  else                  else
138                          can_unlnk = 1;                          can_unlnk = 1;
139                  if (arfd != -1 && gzip_program != NULL)                  if (arfd != -1 && gzip_program != NULL)
140                          ar_start_gzip(arfd, gzip_program, 1);                          ar_start_gzip(arfd, 1);
141                  break;                  break;
142          case APPND:          case APPND:
143                  if (name == NULL) {                  if (name == NULL) {
# Line 395  ar_close(void) Line 397  ar_close(void)
397  #       ifdef LONG_OFF_T  #       ifdef LONG_OFF_T
398                  (void)fprintf(listf, "%s: unknown format, %lu bytes skipped.\n",                  (void)fprintf(listf, "%s: unknown format, %lu bytes skipped.\n",
399  #       else  #       else
400                  (void)fprintf(listf, "%s: unknown format, %qu bytes skipped.\n",                  (void)fprintf(listf, "%s: unknown format, %llu bytes skipped.\n",
401  #       endif  #       endif
402                      argv0, rdcnt);                      argv0, rdcnt);
403                  (void)fflush(listf);                  (void)fflush(listf);
# Line 407  ar_close(void) Line 409  ar_close(void)
409  #       ifdef LONG_OFF_T  #       ifdef LONG_OFF_T
410                  (void)fprintf(listf, "%lu blocks\n", (rdcnt ? rdcnt : wrcnt) / 5120);                  (void)fprintf(listf, "%lu blocks\n", (rdcnt ? rdcnt : wrcnt) / 5120);
411  #       else  #       else
412                  (void)fprintf(listf, "%qu blocks\n", (rdcnt ? rdcnt : wrcnt) / 5120);                  (void)fprintf(listf, "%llu blocks\n", (rdcnt ? rdcnt : wrcnt) / 5120);
413  #       endif  #       endif
414          else if (strcmp(NM_TAR, argv0) != 0)          else if (strcmp(NM_TAR, argv0) != 0)
415                  (void)fprintf(listf,                  (void)fprintf(listf,
416  #       ifdef LONG_OFF_T  #       ifdef LONG_OFF_T
417                      "%s: %s vol %d, %lu files, %lu bytes read, %lu bytes written.\n",                      "%s: %s vol %d, %lu files, %lu bytes read, %lu bytes written.\n",
418  #       else  #       else
419                      "%s: %s vol %d, %lu files, %qu bytes read, %qu bytes written.\n",                      "%s: %s vol %d, %lu files, %llu bytes read, %llu bytes written.\n",
420  #       endif  #       endif
421                      argv0, frmt->name, arvol-1, flcnt, rdcnt, wrcnt);                      argv0, frmt->name, arvol-1, flcnt, rdcnt, wrcnt);
422          (void)fflush(listf);          (void)fflush(listf);
# Line 997  ar_rev(off_t sksz) Line 999  ar_rev(off_t sksz)
999          return(0);          return(0);
1000  }  }
1001    
1002    #ifndef __INTERIX
1003  /*  /*
1004   * get_phys()   * get_phys()
1005   *      Determine the physical block size on a tape drive. We need the physical   *      Determine the physical block size on a tape drive. We need the physical
# Line 1011  ar_rev(off_t sksz) Line 1014  ar_rev(off_t sksz)
1014  static int  static int
1015  get_phys(void)  get_phys(void)
1016  {  {
 #ifndef __INTERIX  
1017          int padsz = 0;          int padsz = 0;
1018          int res;          int res;
1019          int phyblk;          int phyblk;
# Line 1110  get_phys(void) Line 1112  get_phys(void)
1112                  return(-1);                  return(-1);
1113          }          }
1114          return(phyblk);          return(phyblk);
 #else  
         return 0;  
 #endif  
1115  }  }
1116    #endif
1117    
1118  /*  /*
1119   * ar_next()   * ar_next()
# Line 1248  ar_next(void) Line 1248  ar_next(void)
1248                   */                   */
1249                  if (ar_open(buf) >= 0) {                  if (ar_open(buf) >= 0) {
1250                          if (freeit) {                          if (freeit) {
1251                                  (void)free((char *)arcname);                                  free(arcname_);
1252                                  freeit = 0;                                  freeit = 0;
1253                          }                          }
1254                          if ((arcname = strdup(buf)) == NULL) {                          if ((arcname = arcname_ = strdup(buf)) == NULL) {
1255                                  done = 1;                                  done = 1;
1256                                  lstrval = -1;                                  lstrval = -1;
1257                                  paxwarn(0, "Cannot save archive name.");                                  paxwarn(0, "Cannot save archive name.");
# Line 1272  ar_next(void) Line 1272  ar_next(void)
1272   * to keep the fd the same in the calling function (parent).   * to keep the fd the same in the calling function (parent).
1273   */   */
1274  void  void
1275  ar_start_gzip(int fd, const char *gzip_program, int wr)  ar_start_gzip(int fd, int wr)
1276  {  {
1277          int fds[2];          int fds[2];
1278          const char *gzip_flags;          const char *gzip_flags;
# Line 1303  ar_start_gzip(int fd, const char *gzip_p Line 1303  ar_start_gzip(int fd, const char *gzip_p
1303                  }                  }
1304                  close(fds[0]);                  close(fds[0]);
1305                  close(fds[1]);                  close(fds[1]);
1306                  if (execlp(gzip_program, gzip_program, gzip_flags, (char *)NULL) < 0)                  if (execlp(gzip_program, gzip_program, gzip_flags, NULL) < 0)
1307                          err(1, "could not exec");                          err(1, "could not exec");
1308                  /* NOTREACHED */                  /* NOTREACHED */
1309          }          }

Legend:
Removed from v.2714  
changed lines
  Added in v.2715

root@freewrt.org:443
ViewVC Help
Powered by ViewVC 1.1.20