X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=src%2Ftar.c;h=6f21cb58f51d703679585e44b70bf828c15467f5;hb=3ae9e5118154f73ab11cbd98172e6bed058b5f1f;hp=692120e0aa0306f4395996812dd5b6963b65da74;hpb=fb7b2f36450ef0473a3e528421407b9be4d51d74;p=chaz%2Ftar diff --git a/src/tar.c b/src/tar.c index 692120e..6f21cb5 100644 --- a/src/tar.c +++ b/src/tar.c @@ -228,8 +228,10 @@ enum SAME_OWNER_OPTION, SHOW_DEFAULTS_OPTION, SHOW_OMITTED_DIRS_OPTION, + SHOW_STORED_NAMES_OPTION, STRIP_COMPONENTS_OPTION, SUFFIX_OPTION, + TEST_LABEL_OPTION, TO_COMMAND_OPTION, TOTALS_OPTION, UNQUOTE_OPTION, @@ -295,6 +297,8 @@ static struct argp_option options[] = { {"concatenate", 0, 0, OPTION_ALIAS, NULL, 10}, {"delete", DELETE_OPTION, 0, 0, N_("delete from the archive (not on mag tapes!)"), 10 }, + {"test-label", TEST_LABEL_OPTION, NULL, 0, + N_("Test archive volume label and exit"), 10 }, {NULL, 0, NULL, 0, N_("Operation modifiers:"), 20}, @@ -310,7 +314,7 @@ static struct argp_option options[] = { {"occurrence", OCCURRENCE_OPTION, N_("NUMBER"), OPTION_ARG_OPTIONAL, N_("process only the NUMBERth occurrence of each file in the archive. This option is valid only in conjunction with one of the subcommands --delete, --diff, --extract or --list and when a list of files is given either on the command line or via -T option. NUMBER defaults to 1."), 21 }, {"seek", 'n', NULL, 0, - N_("archive is seekable"), 21 }, + N_("archive is seekable"), 21 }, {NULL, 0, NULL, 0, N_("Overwrite control:"), 30}, @@ -550,7 +554,10 @@ static struct argp_option options[] = { N_("Show tar defaults"), 102 }, {"show-omitted-dirs", SHOW_OMITTED_DIRS_OPTION, 0, 0, N_("When listing or extracting, list each directory that does not match search criteria"), 102 }, - + {"show-stored-names", SHOW_STORED_NAMES_OPTION, 0, 0, + N_("When creating archive in verbose mode, list member names as stored in the archive"), + 102 }, + {NULL, 0, NULL, 0, N_("Compatibility options:"), 110 }, @@ -656,7 +663,7 @@ read_name_from_file (FILE *fp, struct obstack *stk) { int c; size_t counter = 0; - + for (c = getc (fp); c != EOF && c != filename_terminator; c = getc (fp)) { if (c == 0) @@ -721,7 +728,7 @@ update_argv (const char *filename, struct argp_state *state) size_t new_argc; bool is_stdin = false; enum read_file_list_state read_state; - + if (!strcmp (filename, "-")) { is_stdin = true; @@ -741,7 +748,7 @@ update_argv (const char *filename, struct argp_state *state) if (read_state == file_list_zero) { size_t size; - + WARN ((0, 0, N_("%s: file name read contains nul character"), quotearg_colon (filename))); @@ -751,7 +758,7 @@ update_argv (const char *filename, struct argp_state *state) for (; size > 0; size--, p++) if (*p) obstack_1grow (&argv_stk, *p); - else + else obstack_1grow (&argv_stk, '\n'); obstack_1grow (&argv_stk, 0); count = 1; @@ -973,15 +980,14 @@ parse_opt (int key, char *arg, struct argp_state *state) stat_error (arg); USAGE_ERROR ((0, 0, _("Date sample file not found"))); } - newer_mtime_option.tv_sec = st.st_mtime; - newer_mtime_option.tv_nsec = TIMESPEC_NS (st.st_mtim); + newer_mtime_option = get_stat_mtime (&st); } else { if (! get_date (&newer_mtime_option, arg, NULL)) { WARN ((0, 0, _("Substituting %s for unknown date format %s"), - tartime (newer_mtime_option.tv_sec), quote (arg))); + tartime (newer_mtime_option, false), quote (arg))); newer_mtime_option.tv_nsec = 0; } else @@ -1037,6 +1043,11 @@ parse_opt (int key, char *arg, struct argp_state *state) verbose_option++; break; + case TEST_LABEL_OPTION: + set_subcommand_option (LIST_SUBCOMMAND); + test_label_option = true; + break; + case 'T': update_argv (arg, state); /* Indicate we've been given -T option. This is for backward @@ -1309,6 +1320,10 @@ parse_opt (int key, char *arg, struct argp_state *state) show_omitted_dirs_option = true; break; + case SHOW_STORED_NAMES_OPTION: + show_stored_names_option = true; + break; + case SUFFIX_OPTION: backup_option = true; args->backup_suffix_string = arg; @@ -1744,8 +1759,11 @@ decode_options (int argc, char **argv) { if (multi_volume_option) USAGE_ERROR ((0, 0, _("Cannot use multi-volume compressed archives"))); - if (subcommand_option == UPDATE_SUBCOMMAND) + if (subcommand_option == UPDATE_SUBCOMMAND + || subcommand_option == APPEND_SUBCOMMAND) USAGE_ERROR ((0, 0, _("Cannot update compressed archives"))); + if (subcommand_option == CAT_SUBCOMMAND) + USAGE_ERROR ((0, 0, _("Cannot concatenate compressed archives"))); } /* It is no harm to use --pax-option on non-pax archives in archive @@ -1763,7 +1781,15 @@ decode_options (int argc, char **argv) if (recursive_unlink_option) old_files_option = UNLINK_FIRST_OLD_FILES; - if (utc_option) + + if (test_label_option) + { + /* --test-label is silent if the user has specified the label name to + compare against. */ + if (args.input_files == 0) + verbose_option++; + } + else if (utc_option) verbose_option = 2; /* Forbid using -c with no input files whatsoever. Check that `-f -', @@ -1819,16 +1845,10 @@ decode_options (int argc, char **argv) if (verbose_option && args.textual_date_option) { - /* FIXME: tartime should support nanoseconds, too, so that this - comparison doesn't complain about lost nanoseconds. */ - char const *treated_as = tartime (newer_mtime_option.tv_sec); + char const *treated_as = tartime (newer_mtime_option, true); if (strcmp (args.textual_date_option, treated_as) != 0) - WARN ((0, 0, - ngettext ("Treating date `%s' as %s + %ld nanosecond", - "Treating date `%s' as %s + %ld nanoseconds", - newer_mtime_option.tv_nsec), - args.textual_date_option, treated_as, - newer_mtime_option.tv_nsec)); + WARN ((0, 0, _("Treating date `%s' as %s"), + args.textual_date_option, treated_as)); } }