X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=src%2Ftar.c;h=2cc37b4f34e7fe39f752d40e9a9f7d2a70504f24;hb=eed93f9a58ed79ec07028b85d54804f042bf7af9;hp=a5987dec2bd3017fa55aa9255dae641ca3ddd9b4;hpb=3350a37816f86b941c28411d67cebb3f9a1a612d;p=chaz%2Ftar diff --git a/src/tar.c b/src/tar.c index a5987de..2cc37b4 100644 --- a/src/tar.c +++ b/src/tar.c @@ -1,5 +1,5 @@ /* Tar -- a tape archiver. - Copyright (C) 1988, 1992 Free Software Foundation + Copyright (C) 1988, 1992, 1993 Free Software Foundation This file is part of GNU Tar. @@ -27,7 +27,6 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ #include /* Needed for typedefs in tar.h */ #include "getopt.h" #include "regex.h" -#include "fnmatch.h" /* * The following causes "tar.h" to produce definitions of all the @@ -37,28 +36,7 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "tar.h" #include "port.h" - -#if defined(_POSIX_VERSION) || defined(DIRENT) -#include -#ifdef direct -#undef direct -#endif /* direct */ -#define direct dirent -#define DP_NAMELEN(x) strlen((x)->d_name) -#endif /* _POSIX_VERSION or DIRENT */ -#if !defined(_POSIX_VERSION) && !defined(DIRENT) && defined(BSD42) -#include -#define DP_NAMELEN(x) (x)->d_namlen -#endif /* not _POSIX_VERSION and BSD42 */ -#ifdef __MSDOS__ -#include "msd_dir.h" -#define DP_NAMELEN(x) (x)->d_namlen -#define direct dirent -#endif -#if defined(USG) && !defined(_POSIX_VERSION) && !defined(DIRENT) -#include -#define DP_NAMELEN(x) strlen((x)->d_name) -#endif /* USG and not _POSIX_VERSION and not DIRENT */ +#include "fnmatch.h" /* * We should use a conversion routine that does reasonable error @@ -159,7 +137,6 @@ struct option long_options[] = {"to-stdout", 0, &f_exstdout, 1}, {"ignore-zeros", 0, &f_ignorez, 1}, {"keep-old-files", 0, 0, 'k'}, - {"uncompress", 0, &f_compress, 1}, {"same-permissions", 0, &f_use_protection, 1}, {"preserve-permissions", 0, &f_use_protection, 1}, {"modification-time", 0, &f_modified, 1}, @@ -175,6 +152,7 @@ struct option long_options[] = {"listed-incremental", 1, 0, 'g'}, {"multi-volume", 0, &f_multivol, 1}, {"info-script", 1, 0, 'F'}, + {"new-volume-script", 1, 0, 'F'}, {"absolute-paths", 0, &f_absolute_paths, 1}, {"interactive", 0, &f_confirm, 1}, {"confirmation", 0, &f_confirm, 1}, @@ -184,8 +162,15 @@ struct option long_options[] = {"one-file-system", 0, &f_local_filesys, 1}, {"old-archive", 0, 0, 'o'}, {"portability", 0, 0, 'o'}, - {"compress", 0, &f_compress, 1}, - {"compress-block", 0, &f_compress, 2}, + {"compress", 0, 0, 'Z'}, + {"uncompress", 0, 0, 'Z'}, + {"block-compress", 0, &f_compress_block, 1}, + {"gzip", 0, 0, 'z'}, + {"ungzip", 0, 0, 'z'}, + {"use-compress-program", 1, 0, 18}, + + + {"same-permissions", 0, &f_use_protection, 1}, {"sparse", 0, &f_sparse_files, 1}, {"tape-length", 1, 0, 'L'}, {"remove-files", 0, &f_remove_files, 1}, @@ -310,7 +295,7 @@ options (argc, argv) /* Set default option values */ blocking = DEFBLOCKING; /* From Makefile */ - ar_files = (char **) malloc (sizeof (char *) * 10); + ar_files = (char **) ck_malloc (sizeof (char *) * 10); ar_files_len = 10; n_ar_files = 0; cur_ar_file = 0; @@ -367,6 +352,15 @@ options (argc, argv) f_volno_file = optarg; break; + case 18: + if (f_compressprog) + { + msg ("Only one compression option permitted\n"); + exit (EX_ARGSBAD); + } + f_compressprog = optarg; + break; + case 'g': /* We are making a GNU dump; save directories at the beginning of the archive, and include in each @@ -623,9 +617,22 @@ options (argc, argv) add_exclude_file (optarg); break; - case 'z': /* Easy to type */ - case 'Z': /* Like the filename extension .Z */ - f_compress++; + case 'z': + if (f_compressprog) + { + msg ("Only one compression option permitted\n"); + exit (EX_ARGSBAD); + } + f_compressprog = "gzip"; + break; + + case 'Z': + if (f_compressprog) + { + msg ("Only one compression option permitted\n"); + exit (EX_ARGSBAD); + } + f_compressprog = "compress"; break; case '?': @@ -649,6 +656,12 @@ options (argc, argv) msg ("Multiple archive files requires --multi-volume\n"); exit (EX_ARGSBAD); } + if (f_compress_block && !f_compressprog) + { + msg ("You must use a compression option (--gzip, --compress\n\ +or --use-compress-program) with --block-compress.\n"); + exit (EX_ARGSBAD); + } } @@ -670,7 +683,7 @@ describe () -c, --create create a new archive\n\ -d, --diff,\n\ --compare find differences between archive and file system\n\ ---delete delete from the archive (not for use on mag tapes!)\n\ +--delete delete from the archive (not for use on mag tapes!)\n\ -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\ @@ -691,22 +704,23 @@ Other options:\n\ DEF_AR_FILE); fputs ("\ --force-local archive file is local even if has a colon\n\ --F, --info-script F run script at end of each tape (implies -M)\n\ +-F, --info-script F\n\ + --new-volume-script F run script at end of each tape (implies -M)\n\ -G, --incremental create/list/extract old GNU-format incremental backup\n\ -g, --listed-incremental F create/list/extract new 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\ --ignore-failed-read don't exit with non-zero status on unreadable files\n\ -k, --keep-old-files keep existing files; don't overwrite them from archive\n\ --K, --starting-file FILE begin at FILE in the 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\ --L, --tape-length LENGTH change tapes after writing LENGTH\n\ +-L, --tape-length N change tapes after writing N*1024 bytes\n\ ", stdout); /* KLUDGE */ 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,\n\ - --newer DATE only store files newer than DATE\n\ + --newer DATE only store files newer than DATE\n\ -o, --old-archive,\n\ --portability write a V7 format archive, rather than ANSI format\n\ -O, --to-stdout extract files to standard output\n\ @@ -724,9 +738,9 @@ Other options:\n\ -S, --sparse handle sparse files efficiently\n\ -T, --files-from F get names to extract or create from file F\n\ --null -T reads null-terminated names, disable -C\n\ ---totals print total bytes written with --create\n\ +--totals print total bytes written with --create\n\ -v, --verbose verbosely list files processed\n\ --V, --label NAME create archive with volume name NAME\n\ +-V, --label NAME create archive with volume name NAME\n\ --version print tar program version number\n\ -w, --interactive,\n\ --confirmation ask for confirmation for every action\n\ @@ -735,8 +749,13 @@ Other options:\n\ -W, --verify attempt to verify the archive after writing it\n\ --exclude FILE exclude file FILE\n\ -X, --exclude-from FILE exclude files listed in FILE\n\ --z, -Z, --compress,\n\ +-Z, --compress,\n\ --uncompress filter the archive through compress\n\ +-z, --gzip,\n\ + --ungzip filter the archive through gzip\n\ +--use-compress-program PROG\n\ + filter the archive through PROG (which must accept -d)\n\ +--block-compress block the output of compression program for tapes\n\ -[0-7][lmh] specify drive and density\n\ ", stdout); } @@ -888,8 +907,10 @@ tryagain: } /* End of JF quick -C hack */ +#if 0 if (f_exclude && check_exclude (p)) goto tryagain; +#endif return un_quote_string (p); } while (p = read_name_from_file (buffer, &buffer_siz, namef)) @@ -913,8 +934,10 @@ tryagain: next_name_is_dir = 0; goto tryagain; } +#if 0 if (f_exclude && check_exclude (p)) goto tryagain; +#endif return un_quote_string (p); } return NULL; @@ -1018,7 +1041,7 @@ addname (name) if (chdir_name[0] != '/') { char *path = ck_malloc (PATH_MAX); -#if defined(__MSDOS__) || defined(USG) || defined(_POSIX_VERSION) +#if defined(__MSDOS__) || defined(HAVE_GETCWD) || defined(_POSIX_VERSION) if (!getcwd (path, PATH_MAX)) { msg ("Couldn't get current directory."); @@ -1117,7 +1140,7 @@ again: /* Regular expressions (shell globbing, actually). */ if (nlp->regexp) { - if (fnmatch (nlp->name, p, FNM_TARPATH) == 0) + if (fnmatch (nlp->name, p, FNM_LEADING_DIR) == 0) { nlp->found = 1; /* Remember it matched */ if (f_startfile) @@ -1236,7 +1259,7 @@ again: /* Regular expressions */ if (nlp->regexp) { - if (fnmatch (nlp->name, p, FNM_TARPATH) == 0) + if (fnmatch (nlp->name, p, FNM_LEADING_DIR) == 0) return nlp; /* We got a match */ continue; } @@ -1464,7 +1487,7 @@ check_exclude (name) for (n = 0; n < size_re_exclude; n++) { - if (fnmatch (re_exclude[n], name, FNM_TARPATH) == 0) + if (fnmatch (re_exclude[n], name, FNM_LEADING_DIR) == 0) return 1; } for (n = 0; n < size_exclude; n++)