diff -cbBw orig/buffer.c tar/buffer.c *** orig/buffer.c Tue Nov 06 19:00:30 1990 --- tar/buffer.c Sat Oct 27 21:07:38 1990 *************** *** 31,37 **** #include #include ! #ifndef MSDOS #include #if !defined(USG) || defined(HAVE_MTIO) #include --- 31,39 ---- #include #include ! #ifdef MSDOS ! #include ! #else #include #if !defined(USG) || defined(HAVE_MTIO) #include *************** *** 48,54 **** --- 50,58 ---- # include #endif + #ifndef MSDOS extern int errno; + #endif #include "tar.h" #include "port.h" *************** *** 139,145 **** /* * Have we hit EOF yet? */ ! static int eof; /* JF we're reading, but we just read the last record and its time to update */ extern time_to_start_writing; --- 143,149 ---- /* * Have we hit EOF yet? */ ! static int _eof; /* JF we're reading, but we just read the last record and its time to update */ extern time_to_start_writing; *************** *** 167,174 **** void reset_eof() { ! if(eof) { ! eof=0; ar_record=ar_block; ar_last=ar_block+blocking; ar_reading=0; --- 171,178 ---- void reset_eof() { ! if(_eof) { ! _eof=0; ar_record=ar_block; ar_last=ar_block+blocking; ar_reading=0; *************** *** 184,194 **** findrec() { if (ar_record == ar_last) { ! if (eof) return (union record *)NULL; /* EOF */ flush_archive(); if (ar_record == ar_last) { ! eof++; return (union record *)NULL; /* EOF */ } } --- 188,198 ---- findrec() { if (ar_record == ar_last) { ! if (_eof) return (union record *)NULL; /* EOF */ flush_archive(); if (ar_record == ar_last) { ! _eof++; return (union record *)NULL; /* EOF */ } } *************** *** 1201,1206 **** --- 1205,1214 ---- system(info_script); else for(;;) { fprintf(msg_file,"Prepare volume #%d and hit return: ",volno); + #ifdef MSDOS + while (kbhit()) + getch(); + #endif if(fgets(inbuf,sizeof(inbuf),read_file)==0 || inbuf[0]=='\n') break; switch(inbuf[0]) { diff -cbBw orig/create.c tar/create.c *** orig/create.c Tue Nov 06 19:00:32 1990 --- tar/create.c Sat Oct 27 21:24:24 1990 *************** *** 26,32 **** --- 26,34 ---- */ #include #include + #ifndef MSDOS #include + #endif #include /* JF: this one is my fault */ *************** *** 245,255 **** --- 247,259 ---- return; } + #ifndef MSDOS /* See if we are trying to dump the archive */ if(ar_dev && hstat.st_dev==ar_dev && hstat.st_ino==ar_ino) { msg("%s is the archive; not dumped",p); return; } + #endif /* * Check for multiple links. * diff -cbBw orig/diffarch.c tar/diffarch.c *** orig/diffarch.c Tue Nov 06 19:01:54 1990 --- tar/diffarch.c Sat Oct 27 21:37:02 1990 *************** *** 45,50 **** --- 45,54 ---- #include #endif + #ifdef MSDOS + #include + #endif + /* Some systems don't have these #define's -- we fake it here. */ #ifndef O_RDONLY #define O_RDONLY 0 *************** *** 57,63 **** --- 61,69 ---- #define lstat stat #endif + #ifndef MSDOS extern int errno; /* From libc.a */ + #endif extern char *valloc(); /* From libc.a */ #include "tar.h" *************** *** 187,193 **** goto quit; } ! diff_fd = open(head->header.name, O_NDELAY|O_RDONLY); if (diff_fd < 0 && !f_absolute_paths) { char tmpbuf[NAMSIZ+2]; --- 193,199 ---- goto quit; } ! diff_fd = open(head->header.name, O_NDELAY|O_RDONLY|O_BINARY); if (diff_fd < 0 && !f_absolute_paths) { char tmpbuf[NAMSIZ+2]; *************** *** 194,200 **** tmpbuf[0]='/'; strcpy(&tmpbuf[1],head->header.name); ! diff_fd=open(tmpbuf, O_NDELAY|O_RDONLY); } if (diff_fd < 0) { msg_perror("cannot open %s",head->header.name); --- 200,206 ---- tmpbuf[0]='/'; strcpy(&tmpbuf[1],head->header.name); ! diff_fd=open(tmpbuf, O_NDELAY|O_RDONLY|O_BINARY); } if (diff_fd < 0) { msg_perror("cannot open %s",head->header.name); *************** *** 353,359 **** break; } ! diff_fd = open(head->header.name, O_NDELAY|O_RDONLY); if (diff_fd < 0) { msg_perror("cannot open file %s",head->header.name); --- 359,365 ---- break; } ! diff_fd = open(head->header.name, O_NDELAY|O_RDONLY|O_BINARY); if (diff_fd < 0) { msg_perror("cannot open file %s",head->header.name); diff -cbBw orig/extract.c tar/extract.c *** orig/extract.c Tue Nov 06 19:00:40 1990 --- tar/extract.c Sun Oct 28 14:53:02 1990 *************** *** 62,68 **** --- 62,70 ---- #include "open3.h" #endif + #ifndef MSDOS extern int errno; /* From libc.a */ + #endif extern time_t time(); /* From libc.a */ extern char *index(); /* From libc.a or port.c */ *************** *** 173,178 **** --- 175,185 ---- } } + #ifdef MSDOS + if ( IsFileSystemFAT(head->header.name + skipcrud) ) + ChangeNameForFAT(head->header.name + skipcrud); + #endif + switch (head->header.linkflag) { default: *************** *** 486,495 **** acc_upd_times[0]=hstat.st_atime; else acc_upd_times[0] = now; /* Accessed now */ acc_upd_times[1] = hstat.st_mtime; /* Mod'd */ ! if (utime(skipcrud+head->header.name, ! acc_upd_times) < 0) { msg_perror("couldn't change access and modification times of %s",skipcrud+head->header.name); ! } } quit: --- 493,507 ---- acc_upd_times[0]=hstat.st_atime; else acc_upd_times[0] = now; /* Accessed now */ acc_upd_times[1] = hstat.st_mtime; /* Mod'd */ ! #ifdef MSDOS ! chmod(skipcrud+head->header.name, S_IWRITE); ! if (utime(skipcrud+head->header.name, acc_upd_times) < 0) ! msg_perror("couldn't change modification time of %s",skipcrud+head->header.name); ! chmod(skipcrud+head->header.name, (int)hstat.st_mode); ! #else ! if (utime(skipcrud+head->header.name, acc_upd_times) < 0) msg_perror("couldn't change access and modification times of %s",skipcrud+head->header.name); ! #endif } quit: *************** *** 593,599 **** --- 605,616 ---- skipcrud+head->header.name); } + #ifdef MSDOS + goto quit; /* no chmod() and chown() allowed on directories + under MS-DOS and OS/2 1.1 */ + #else goto set_filestat; + #endif /* FIXME, Remember timestamps for after files created? */ /* FIXME, change mode after files created (if was R/O dir) */ case LF_VOLHDR: diff -cbBw orig/getdate.y tar/getdate.y *** orig/getdate.y Tue Nov 06 19:00:40 1990 --- tar/getdate.y Sat Oct 27 20:43:42 1990 *************** *** 58,63 **** --- 58,65 ---- static time_t timeconv(); static time_t daylcorr(); static lookup(); + static yylex(); + static yyerror(); static int yylex (); #define yyparse getdate_yyparse diff -cbBw orig/getopt.c tar/getopt.c *** orig/getopt.c Tue Nov 06 19:00:42 1990 --- tar/getopt.c Sat Oct 27 23:04:34 1990 *************** *** 15,25 **** along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ ! #ifdef __STDC__ #define CONST const #else #define CONST #endif /* This version of `getopt' appears to the caller like standard Unix `getopt' but it behaves differently for the user, since it allows the user --- 15,28 ---- along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ ! #if defined(__STDC__) || defined(MSDOS) #define CONST const #else #define CONST #endif + #ifdef MSDOS + #define STDC_HEADERS + #endif /* This version of `getopt' appears to the caller like standard Unix `getopt' but it behaves differently for the user, since it allows the user *************** *** 44,51 **** --- 47,58 ---- #ifdef sparc #include #else + #ifdef MSDOS + #include + #else char *alloca (); #endif + #endif #endif /* not __GNUC__ */ #if defined(STDC_HEADERS) || defined(__GNU_LIBRARY__) *************** *** 68,73 **** --- 75,82 ---- char *malloc (); #endif + static void exchange (char **); + /* For communication from `getopt' to the caller. When `getopt' finds an option that takes an argument, the argument value is returned here. *************** *** 372,378 **** p++, option_index++) if (!strncmp (p->name, nextchar, s - nextchar)) { ! if (s - nextchar == strlen (p->name)) { /* Exact match found. */ pfound = p; --- 381,387 ---- p++, option_index++) if (!strncmp (p->name, nextchar, s - nextchar)) { ! if (s - nextchar == (int) strlen (p->name)) { /* Exact match found. */ pfound = p; diff -cbBw orig/getopt.h tar/getopt.h *** orig/getopt.h Tue Nov 06 19:00:42 1990 --- tar/getopt.h Sat Oct 27 23:04:34 1990 *************** *** 70,76 **** int val; }; ! #ifdef __STDC__ extern const struct option *_getopt_long_options; #else extern struct option *_getopt_long_options; --- 70,76 ---- int val; }; ! #if defined(__STDC__) || defined(MSDOS) extern const struct option *_getopt_long_options; #else extern struct option *_getopt_long_options; *************** *** 87,93 **** extern int option_index; ! #ifdef __STDC__ int getopt (int argc, char **argv, const char *shortopts); int getopt_long (int argc, char **argv, const char *shortopts, const struct option *longopts, int *longind); --- 87,93 ---- extern int option_index; ! #if defined(__STDC__) || defined(MSDOS) int getopt (int argc, char **argv, const char *shortopts); int getopt_long (int argc, char **argv, const char *shortopts, const struct option *longopts, int *longind); diff -cbBw orig/getopt1.c tar/getopt1.c *** orig/getopt1.c Tue Nov 06 19:00:44 1990 --- tar/getopt1.c Sat Oct 27 23:04:36 1990 *************** *** 17,23 **** #include "getopt.h" ! #ifdef __STDC__ #define CONST const #else #define CONST --- 17,23 ---- #include "getopt.h" ! #if defined(__STDC__) || defined(MSDOS) #define CONST const #else #define CONST *************** *** 38,43 **** --- 38,44 ---- int val; _getopt_long_options = long_options; + _getopt_long_only = 0; val = getopt (argc, argv, options); if (val == 0 && opt_index != NULL) *opt_index = option_index; diff -cbBw orig/gnu.c tar/gnu.c *** orig/gnu.c Tue Nov 06 19:00:46 1990 --- tar/gnu.c Tue Nov 06 19:28:16 1990 *************** *** 30,35 **** --- 30,39 ---- #endif #endif + #ifndef S_IFLNK + #define lstat stat + #endif + #ifndef DP_NAMELEN #define DP_NAMELEN(x) (x)->d_namlen #endif *************** *** 166,171 **** --- 170,177 ---- return 0; } + + static void add_dir_name(); /* Collect all the names from argv[] (or whatever), then expand them into a directory tree, and put all the directories at the beginning. */ diff -cbBw orig/list.c tar/list.c *** orig/list.c Tue Nov 06 19:00:46 1990 --- tar/list.c Sat Oct 27 20:43:46 1990 *************** *** 487,492 **** --- 487,494 ---- /* Timestamp */ longie = hstat.st_mtime; timestamp = ctime(&longie); + if (timestamp==NULL) + timestamp="--- --- -- --:--:-- ----\n"; timestamp[16] = '\0'; timestamp[24] = '\0'; *************** *** 577,587 **** break; case LF_VOLHDR: ! fprintf(msg_file, "--Volume Header--\n"); break; case LF_MULTIVOL: ! fprintf(msg_file, "--Continued at byte %ld--\n",from_oct(1+12,head->header.offset)); break; } } --- 579,589 ---- break; case LF_VOLHDR: ! fprintf(msg_file, " (Volume Header)\n"); break; case LF_MULTIVOL: ! fprintf(msg_file, " (Continued at byte %ld)\n",from_oct(1+12,head->header.offset)); break; } } diff -cbBw orig/port.c tar/port.c *** orig/port.c Tue Nov 06 19:00:48 1990 --- tar/port.c Sat Oct 27 20:48:26 1990 *************** *** 113,118 **** --- 113,119 ---- #define WANT_MKNOD #define WANT_UTILS #define WANT_VALLOC + #define STDC_MSG #if (!defined(STDC_MSG) && !defined(DOPRNT_MSG) && !defined(VARARGS_MSG) && !defined(LOSING_MSG)) #ifdef __STDC__ *************** *** 159,165 **** into a time_t . Its not well tested or anything. . . */ /* In general, you should use the getdate() supplied in getdate.y */ ! #define OFF_FROM GMT 18000 /* Change for your time zone! */ time_t getdate(str) --- 160,167 ---- into a time_t . Its not well tested or anything. . . */ /* In general, you should use the getdate() supplied in getdate.y */ ! /* #define OFF_FROM_GMT 18000 /* Change for your time zone! */ ! #define OFF_FROM_GMT 0 /* Change for your time zone! */ time_t getdate(str) *************** *** 255,261 **** --- 257,265 ---- { int cpid, status; struct stat statbuf; + #ifndef MSDOS extern int errno; + #endif if (stat(dpath,&statbuf) == 0) { errno = EEXIST; /* Stat worked, so it already exists */ *************** *** 649,655 **** --- 653,661 ---- unsigned short mode; dev_t dev; { + #ifndef MSDOS extern int errno; + #endif int fd; errno = ENXIO; /* No such device or address */ *************** *** 1156,1162 **** --- 1162,1170 ---- { va_list args; int save_e; + #ifndef MSDOS extern int errno; + #endif save_e=errno; fflush(msg_file); diff -cbBw orig/rmt.h tar/rmt.h *** orig/rmt.h Tue Nov 06 19:00:48 1990 --- tar/rmt.h Sat Oct 27 20:43:48 1990 *************** *** 36,43 **** --- 36,45 ---- extern long lseek(); #else #ifndef USG + #ifndef MSDOS #define strchr index #endif + #endif #define __REM_BIAS 128 #define RMTIOCTL *************** *** 45,60 **** #ifndef O_CREAT #define O_CREAT 01000 #endif - extern char *__rmt_path; extern char *strchr(); ! #define _remdev(path) ((__rmt_path=strchr(path, ':')) && strncmp(__rmt_path, ":/dev/", 6)==0) #define _isrmt(fd) ((fd) >= __REM_BIAS) ! #define rmtopen(path,oflag,mode) (_remdev(path) ? __rmt_open(path, oflag, mode, __REM_BIAS) : open(path, oflag, mode)) #define rmtaccess(path, amode) (_remdev(path) ? 0 : access(path, amode)) #define rmtstat(path, buf) (_remdev(path) ? (errno = EOPNOTSUPP), -1 : stat(path, buf)) ! #define rmtcreat(path, mode) (_remdev(path) ? __rmt_open (path, 1 | O_CREAT, mode, __REM_BIAS) : creat(path, mode)) #define rmtlstat(path,buf) (_remdev(path) ? (errno = EOPNOTSUPP), -1 : lstat(path,buf)) #define rmtread(fd, buf, n) (_isrmt(fd) ? __rmt_read(fd - __REM_BIAS, buf, n) : read(fd, buf, n)) --- 47,61 ---- #ifndef O_CREAT #define O_CREAT 01000 #endif extern char *strchr(); ! #define _remdev(path) ((path[1] == ':' && path[2] == 0)) #define _isrmt(fd) ((fd) >= __REM_BIAS) ! #define rmtopen(path,oflag,mode) (_remdev(path) ? __rmt_open(path, oflag, mode) + __REM_BIAS : open(path, oflag, mode)) #define rmtaccess(path, amode) (_remdev(path) ? 0 : access(path, amode)) #define rmtstat(path, buf) (_remdev(path) ? (errno = EOPNOTSUPP), -1 : stat(path, buf)) ! #define rmtcreat(path, mode) (_remdev(path) ? __rmt_open (path, 1 | O_CREAT, mode) + __REM_BIAS : creat(path, mode)) #define rmtlstat(path,buf) (_remdev(path) ? (errno = EOPNOTSUPP), -1 : lstat(path,buf)) #define rmtread(fd, buf, n) (_isrmt(fd) ? __rmt_read(fd - __REM_BIAS, buf, n) : read(fd, buf, n)) diff -cbBw orig/tar.c tar/tar.c *** orig/tar.c Tue Nov 06 19:00:52 1990 --- tar/tar.c Tue Nov 06 18:57:56 1990 *************** *** 237,244 **** --- 237,254 ---- read_and(diff_archive); break; case CMD_NONE: + #ifdef MSDOS + if ( argc > 1 ) + { + msg("you must specify exactly one of the r, c, t, x, or d options\n"); + fprintf(stderr,"For more information, type ``%s +help''.\n",tar); + } + else + describe(); + #else msg("you must specify exactly one of the r, c, t, x, or d options\n"); fprintf(stderr,"For more information, type ``%s +help''.\n",tar); + #endif exit(EX_ARGSBAD); } exit(0); *************** *** 312,317 **** --- 322,336 ---- case '0': case '1': + #ifdef MSDOS + { + static char buf[8]; + + sprintf(buf,"%c:",c); + ar_file=buf; + } + break; + #else case '2': case '3': case '4': *************** *** 343,348 **** --- 362,368 ---- ar_file=buf; } break; + #endif case 'A': /* Arguments are tar files, just cat them onto the end *************** *** 558,564 **** --- 578,637 ---- void describe() { + extern char version_string[]; + + #ifdef MSDOS + fprintf(stdout,"\n%s\n\n",version_string); + #endif msg("choose one of the following:"); + + #ifdef MSDOS + fputs(" -A, +catenate append tar files to an archive\n" + " -c, +create create a new archive\n" + " -d, +diff find differences between archive and file system\n" + " +delete delete from the archive (not for use on mag tapes!)\n",stdout); + fputs(" -r, +append append files to the end of an archive\n" + " -t, +list list the contents of an archive\n" + " -u, +update only append files that are newer than copy in archive\n" + " -x, +extract extract files from an archive\n",stdout); + + fputs("\nOther options:\n" + " -b, +block-size N block size of Nx512 bytes\n" + " -B, +read-full-blocks reblock as we read (for reading 4.2BSD pipes)\n" + " -C, +directory DIR change to directory DIR\n", stdout); + + fputs(" -f, +file F use archive file or device F (or hostname:/dev/file)\n" + " -G, +incremental F create/list/extract GNU-format incremental backup\n" + " -h, +dereference don't dump symlinks; dump the files they point to\n" + " -i, +ignore-zeros ignore blocks of zeros in archive (normally mean EOF)\n", stdout); + fputs(" -k, +keep-old-files keep existing files; don't overwrite from archive\n" + " -K, +starting-file F begin at file F in the archive\n" + " -l, +one-file-system stay in local file system when creating an archive\n", stdout); + + fputs(" -m, +modification-time don't extract file modified time\n" + " -M, +multi-volume create/list/extract multi-volume archive\n" + " -N, +after-date DATE only store files newer than DATE\n" + " -o, +old-archive write a V7 format archive, rather than ANSI format\n" + " -O, +to-stdout extract files to standard output\n" + " -p, +same-permissions extract all protection information\n" + " -P, +absolute-paths don't strip leading \"/\"es from file names\n", stdout); + fputs(" +preserve like -p -s\n" + " -R, +record-number show record number within archive with each message\n" + " -s, +same-order list of names to extract is sorted to match archive\n" + " -S, +sparse handle sparse files specially\n", stdout); + + fputs(" -T, +files-from F get names to extract or create from file F\n" + " -v, +verbose verbosely list files processed\n" + " -V, +volume VNAM create archive with volume name VNAM\n" + " +version print tar program version number\n" + " -w, +interactive ask for confirmation for every action\n" + " -W, +verify attempt to verify the archive after writing it\n" + " -X, +exclude F exclude files listed in file F\n", stdout); + fputs( + " -[01] specify disk drive for \"tape on a disk\"\n" + " (density selfdetected)\n" + , stdout); + #else fputs("\ -A, +catenate append tar files to an archive\n\ -c, +create create a new archive\n\ *************** *** 605,610 **** --- 678,684 ---- -z, -Z, +compress filter the archive through compress\n\ -[0-7][lmh] specify drive and density\n\ ", stderr); + #endif } name_add(name) *************** *** 612,618 **** { if(n_indalloc==n_indused) { n_indalloc+=10; ! n_ind=(char **)(n_indused ? ck_realloc(n_ind,n_indalloc*sizeof(int)) : ck_malloc(n_indalloc*sizeof(int))); } n_ind[n_indused++]=name; } --- 686,692 ---- { if(n_indalloc==n_indused) { n_indalloc+=10; ! n_ind=(char **)(n_indused ? ck_realloc(n_ind,n_indalloc*sizeof(char *)) : ck_malloc(n_indalloc*sizeof(char *))); } n_ind[n_indused++]=name; } *************** *** 779,785 **** --- 853,861 ---- register struct name *p; /* Current struct pointer */ static char *chdir_name; char *new_name(); + #ifndef MAXPATHLEN #define MAXPATHLEN 1024 + #endif if(name[0]=='-' && name[1]=='C' && name[2]=='\0') { chdir_name=name_next(0); diff -cbBw orig/tar.h tar/tar.h *** orig/tar.h Tue Nov 06 19:00:52 1990 --- tar/tar.h Sat Oct 27 20:43:54 1990 *************** *** 27,32 **** --- 27,37 ---- * Created 25 August 1985 by John Gilmore, ihnp4!hoptoad!gnu. */ + #ifdef MSDOS + #define NONAMES + #define DEF_AR_FILE "archive.tar" + #endif + /* * Kludge for handling systems that can't cope with multiple * external definitions of a variable. In ONE routine (tar.c), diff -cbBw orig/update.c tar/update.c *** orig/update.c Tue Nov 06 19:00:54 1990 --- tar/update.c Sat Oct 27 20:43:54 1990 *************** *** 34,40 **** #include #endif ! #ifndef MSDOS #include #include #endif --- 34,42 ---- #include #endif ! #ifdef MSDOS ! #include ! #else #include #include #endif *************** *** 501,507 **** --- 503,511 ---- move_arch(n) { long cur; + #ifndef MSDOS extern int errno; + #endif #ifdef MTIOCTOP struct mtop t; diff -cbBw orig/version.c tar/version.c *** orig/version.c Tue Nov 06 19:00:56 1990 --- tar/version.c Sat Oct 27 21:00:18 1990 *************** *** 17,23 **** along with GNU Tar; see the file COPYING. If not, write to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ ! char version_string[] = "GNU tar version 1.09"; /* Version 1.00: This file added. -version option added */ --- 17,23 ---- along with GNU Tar; see the file COPYING. If not, write to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ ! char version_string[] = "GNU tar version 1.09 (for DOS and OS/2)"; /* Version 1.00: This file added. -version option added */