tarx

Astor Giacomo agiacom en optonline.net
Mie Ago 24 00:07:48 CLT 2005


On Tuesday 23 August 2005 01:41 pm, Horst von Brand wrote:

> Aca va un parche que lo endecenta para el uso de hoy. Ojala funcione...

Compila, pero no funciona. El diff que sigue si hace que funcione (al menos 
por aca).

Saludos,
-ag

--- ../old/tarx.c 2005-08-23 23:02:02.282420270 -0400
+++ tarx.c 2005-08-23 23:01:30.651447490 -0400
@@ -4,6 +4,11 @@
 
 #include <stdio.h>
 #include <string.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <tar.h>
 
 #define NAMSIZ 100  /* why isn't there a tar.h??? */
 #define FLAG (NAMSIZ+8+8+8+12+12+8) /* offset of is-a-link flag */
@@ -11,16 +16,16 @@
  int offset;
  char value;
 } matches[] = {   /* pattern-match table for header blocks */
- NAMSIZ+6, ' ',
- NAMSIZ+7, '\0',
- NAMSIZ+8+6, ' ',
- NAMSIZ+8+7, '\0',
- NAMSIZ+16+6, ' ',
- NAMSIZ+16+7, '\0',
- NAMSIZ+24+11, ' ',
- NAMSIZ+36+11, ' ',
- NAMSIZ+48+6, '\0',
- 0,  0,
+ { NAMSIZ+6, ' '  },
+ { NAMSIZ+7, '\0' },
+ { NAMSIZ+8+6, ' '  },
+ { NAMSIZ+8+7, '\0' },
+ { NAMSIZ+16+6, ' '  },
+ { NAMSIZ+16+7, '\0' },
+ { NAMSIZ+24+11, ' '  },
+ { NAMSIZ+36+11, ' '  },
+ { NAMSIZ+48+6, '\0' },
+ { 0,  0,   }
 };
 
 #ifndef MAXBLOCK
@@ -40,14 +45,14 @@
 
 int opened = 0;   /* are we writing a file? */
 int f;    /* the file descriptor, if any */
-long fsize;   /* number of bytes not yet written to file */
+unsigned long fsize;   /* number of bytes not yet written to file */
 
 char op = 'x';   /* what operation is being done? */
 
 #define STREQ(a, b) (*(a) == *(b) && strcmp((a), (b)) == 0)
 
 #ifndef lint
-static char RCSid[] = "$Header$";
+static const char RCSid[] = "$Header$";
 #endif
 
 int debug = 0;
@@ -60,9 +65,15 @@
 #define mkprogname(a) (a)
 #endif
 
+char *readblock(int);
+void doblock(char *, int, char **);
+int istar(char *);
+int match(char *, int, char **);
+
 /*
  - main - parse arguments and handle options
  */
+int
 main(argc, argv)
 int argc;
 char *argv[];
@@ -70,8 +81,6 @@
  int c;
  int errflg = 0;
  register char *block;
- extern char *readblock();
- extern char *malloc();
  extern int optind;
  extern char *optarg;
 
@@ -129,9 +138,6 @@
 int desc;
 {
  register int count;
- extern int errno;
- extern int sys_nerr;
- extern char *sys_errlist[];
 
  if (nleft > 0) {
   whichnow++;
@@ -149,10 +155,7 @@
    printf("---! bad block size (%d) - treated as bad\n", count);
    nbad++;
   } else {
-   if (errno >= 0 && errno < sys_nerr)
-    printf("---! error (%s)\n", sys_errlist[errno]);
-   else
-    printf("---! error %d\n", errno);
+   printf("---! error (%s)\n", strerror(errno));
    nbad++;
   }
   if (nbad >= badlimit)
@@ -173,6 +176,7 @@
 /*
  - doblock - process a block
  */
+void
 doblock(block, argc, argv)
 char *block;
 int argc;
@@ -252,6 +256,13 @@
   else
    printf("--- symlink %s to %s\n", block+FLAG+1, block);
   break;
+ case '5':
+  f = mkdir(block, 0700);
+  if (f < 0)
+   printf("---! unable to create directory %s\n", block);
+  else
+   printf("--- create directory %s\n", block);
+  break;
  default:
   printf("---! unknown flag value %c\n", block[FLAG]);
   break;
@@ -291,6 +302,8 @@
 {
  register int loop;
 
+ if (!memcmp(block + 257, TMAGIC, TMAGLEN-1))
+  return 1;
  for (loop = 0; matches[loop].offset != 0; loop++)
   if (block[matches[loop].offset] != matches[loop].value)
    return(0);


Más información sobre la lista de distribución Linux