/* Tar -- a tape archiver.
- Copyright (C) 1988 Free Software Foundation
+ Copyright (C) 1988, 1992 Free Software Foundation
This file is part of GNU Tar.
#include <sys/types.h> /* 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
void name_init();
void options();
char *un_quote_string();
-int wildmat();
#ifndef S_ISLNK
#define lstat stat
{"compress-block", 0, &f_compress, 2},
{"sparse", 0, &f_sparse_files, 1},
{"tape-length", 1, 0, 'L'},
+ {"remove-files", 0, &f_remove_files, 1},
+ {"ignore-failed-read", 0, &f_ignore_failed_read, 1},
+ {"checkpoint", 0, &f_checkpoint, 1},
+ {"show-omitted-dirs", 0, &f_show_omitted_dirs, 1},
+ {"volno-file", 1, 0, 17},
+ {"force-local", 0, &f_force_local, 1},
+ {"atime-preserve", 0, &f_atime_preserve, 1},
{0, 0, 0, 0}
};
if(!n_argv)
name_init(argc, argv);
+ if (f_volno_file)
+ init_volume_number ();
+
switch(cmd_mode) {
case CMD_CAT:
case CMD_UPDATE:
break;
case CMD_EXTRACT:
if (f_volhdr) {
- char *err;
+ const char *err;
label_pattern = (struct re_pattern_buffer *)
ck_malloc (sizeof *label_pattern);
err = re_compile_pattern (f_volhdr, strlen (f_volhdr),
break;
case CMD_LIST:
if (f_volhdr) {
- char *err;
+ const char *err;
label_pattern = (struct re_pattern_buffer *)
ck_malloc (sizeof *label_pattern);
err = re_compile_pattern (f_volhdr, strlen (f_volhdr),
break;
case CMD_NONE:
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);
+ fprintf(stderr,"For more information, type ``%s --help''.\n",tar);
exit(EX_ARGSBAD);
}
+ if (f_volno_file)
+ closeout_volume_number ();
exit(errors);
/* NOTREACHED */
}
/* Set default option values */
blocking = DEFBLOCKING; /* From Makefile */
- ar_file = getenv("TAPE"); /* From environment, or */
- if (ar_file == 0)
- ar_file = DEF_AR_FILE; /* From Makefile */
+ ar_files = (char **) malloc (sizeof (char *) * 10);
+ ar_files_len = 10;
+ n_ar_files = 0;
+ cur_ar_file = 0;
/* Parse options */
while ((c = getoldopt(argc, argv,
filename_terminator = '\0';
break;
+ case 17:
+ f_volno_file = optarg;
+ break;
+
case 'g': /* We are making a GNU dump; save
directories at the beginning of
the archive, and include in each
sprintf(buf,"/dev/rmt%d",add+c-'0');
#endif
- ar_file=buf;
+ if (n_ar_files == ar_files_len)
+ ar_files
+ = (char **)
+ ck_malloc (sizeof (char *)
+ * (ar_files_len *= 2));
+ ar_files[n_ar_files++]=buf;
}
break;
break;
case 'f': /* Use ar_file for the archive */
- ar_file = optarg;
+ if (n_ar_files == ar_files_len)
+ ar_files
+ = (char **) ck_malloc (sizeof (char *)
+ * (ar_files_len *= 2));
+
+ ar_files[n_ar_files++] = optarg;
break;
case 'F':
case '?':
badopt:
- msg("Unknown option. Use '%s +help' for a complete list of options.", tar);
+ msg("Unknown option. Use '%s --help' for a complete list of options.", tar);
exit(EX_ARGSBAD);
}
}
blocksize = blocking * RECORDSIZE;
+ if (n_ar_files == 0)
+ {
+ n_ar_files = 1;
+ ar_files[0] = getenv("TAPE"); /* From environment, or */
+ if (ar_files[0] == 0)
+ ar_files[0] = DEF_AR_FILE; /* From Makefile */
+ }
+ if (n_ar_files > 1 && !f_multivol)
+ {
+ msg ("Multiple archive files requires --multi-volume\n");
+ exit (EX_ARGSBAD);
+ }
}
fprintf(stdout, "\
Other options:\n\
+--atime-preserve don't change access times on dumped files\n\
-b, --block-size N block size of Nx512 bytes (default N=%d)\n", DEFBLOCKING);
fputs ("\
-B, --read-full-blocks reblock as we read (for reading 4.2BSD pipes)\n\
-C, --directory DIR change to directory DIR\n\
+--checkpoint print directory names while reading the archive\n\
", stdout); /* KLUDGE */ fprintf(stdout, "\
-f, --file [HOSTNAME:]F use archive file or device F (default %s)\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\
-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\
-l, --one-file-system stay in local file system when creating an archive\n\
--preserve like -p -s\n\
", stdout); /* KLUDGE */ fputs("\
-R, --record-number show record number within archive with each message\n\
+--remove-files remove files after adding them to the archive\n\
-s, --same-order,\n\
--preserve-order list of names to extract is sorted to match archive\n\
---same-order create extracted files with the same ownership \n\
+--same-owner create extracted files with the same ownership \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\
if(chdir_name[0]!='/') {
char *path = ck_malloc(PATH_MAX);
#if defined(__MSDOS__) || defined(USG) || defined(_POSIX_VERSION)
- if(!getcwd(path,PATH_MAX))
+ if(!getcwd(path,PATH_MAX)) {
msg("Couldn't get current directory.");
exit(EX_SYSTEM);
+ }
#else
char *getwd();
/* Regular expressions (shell globbing, actually). */
if (nlp->regexp) {
- if (wildmat(p, nlp->name)) {
+ if (fnmatch(nlp->name, p, FNM_TARPATH) == 0) {
nlp->found = 1; /* Remember it matched */
if(f_startfile) {
free((void *)namelist);
/* Regular expressions */
if (nlp->regexp) {
- if (wildmat(p, nlp->name))
+ if (fnmatch(nlp->name, p, FNM_TARPATH) == 0)
return nlp; /* We got a match */
continue;
}
{
FILE *fp;
char buf[1024];
- extern char *rindex();
if(strcmp(file, "-"))
fp=fopen(file,"r");
extern char *strstr();
for(n=0;n<size_re_exclude;n++) {
- if(wildmat(name,re_exclude[n]))
+ if(fnmatch(re_exclude[n], name, FNM_TARPATH) == 0)
return 1;
}
for(n=0;n<size_exclude;n++) {