]> Dogcows Code - chaz/tar/blobdiff - src/tar.c
Use TAR_VOLUME instead of reading volno file.
[chaz/tar] / src / tar.c
index 8fd0548e0d8641547b506eb7b10a4d64346a74db..d20948b269d7ddfacd7a67efd43aebb11a0139e2 100644 (file)
--- a/src/tar.c
+++ b/src/tar.c
@@ -36,6 +36,7 @@
 #define GLOBAL
 #include "common.h"
 
+#include <argmatch.h>
 #include <getdate.h>
 #include <localedir.h>
 #include <rmt.h>
@@ -113,7 +114,7 @@ confirm (const char *message_action, const char *message_name)
        status = rpmatch (response) > 0;
       free (response);
     }
-  
+
   if (confirm_file_EOF)
     {
       fputc ('\n', stdlis);
@@ -152,7 +153,7 @@ set_archive_format (char const *name)
   archive_format = p->fmt;
 }
 
-static const char *
+const char *
 archive_format_string (enum archive_format fmt)
 {
   struct fmttab const *p;
@@ -173,6 +174,42 @@ assert_format(unsigned fmt_mask)
                  _("GNU features wanted on incompatible archive format")));
 }
 
+const char *
+subcommand_string (enum subcommand c)
+{
+  switch (c)
+    {
+    case UNKNOWN_SUBCOMMAND:
+      return "unknown?";
+
+    case APPEND_SUBCOMMAND:
+      return "-r";
+
+    case CAT_SUBCOMMAND:
+      return "-A";
+      
+    case CREATE_SUBCOMMAND:
+      return "-c";
+      
+    case DELETE_SUBCOMMAND:
+      return "-D";
+
+    case DIFF_SUBCOMMAND:
+      return "-d";
+      
+    case EXTRACT_SUBCOMMAND:
+      return "-x";
+
+    case LIST_SUBCOMMAND:
+      return "-t";
+
+    case UPDATE_SUBCOMMAND:
+      return "-u";
+
+    default:
+      abort ();
+    }
+}
 
 \f
 /* Options.  */
@@ -267,7 +304,7 @@ The version control may be set with --backup or VERSION_CONTROL, values are:\n\n
    [For Solaris tar compatibility =/= Is it important at all?]
    e  exit immediately with a nonzero exit status if unexpected errors occur
    E  use extended headers (--format=posix)
-   
+
    [q  alias for --occurrence=1 =/= this would better be used for quiet?]
    [I  same as T =/= will harm star compatibility]
 
@@ -357,8 +394,11 @@ static struct argp_option options[] = {
    N_("force NAME as group for added files"), 51 },
   {"mode", MODE_OPTION, N_("CHANGES"), 0,
    N_("force (symbolic) mode CHANGES for added files"), 51 },
-  {"atime-preserve", ATIME_PRESERVE_OPTION, 0, 0,
-   N_("don't change access times on dumped files"), 51 },
+  {"atime-preserve", ATIME_PRESERVE_OPTION,
+   N_("METHOD"), OPTION_ARG_OPTIONAL,
+   N_("preserve access times on dumped files, either by restoring the times"
+      " after reading (METHOD='replace'; default) or by not setting the times"
+      " in the first place (METHOD='system')"), 51 },
   {"touch", 'm', 0, 0,
    N_("don't extract file modified time"), 51 },
   {"same-owner", SAME_OWNER_OPTION, 0, 0,
@@ -578,6 +618,17 @@ static struct argp_option options[] = {
   {0, 0, 0, 0, 0, 0}
 };
 
+static char const *const atime_preserve_args[] =
+{
+  "replace", "system", NULL
+};
+static enum atime_preserve const atime_preserve_types[] =
+{
+  replace_atime_preserve, system_atime_preserve
+};
+ARGMATCH_VERIFY (atime_preserve_args, atime_preserve_types);
+
+
 struct tar_args {
   char const *textual_date_option;
   int exclude_options;
@@ -1117,7 +1168,15 @@ parse_opt (int key, char *arg, struct argp_state *state)
       break;
 
     case ATIME_PRESERVE_OPTION:
-      atime_preserve_option = true;
+      atime_preserve_option =
+       (arg
+        ? XARGMATCH ("--atime-preserve", arg,
+                     atime_preserve_args, atime_preserve_types)
+        : replace_atime_preserve);
+      if (! O_NOATIME && atime_preserve_option == system_atime_preserve)
+       FATAL_ERROR ((0, 0,
+                     _("--atime-preserve='system' is not supported"
+                       " on this platform")));
       break;
 
     case CHECKPOINT_OPTION:
@@ -1872,7 +1931,7 @@ main (int argc, char **argv)
 
   /* Make sure we have first three descriptors available */
   stdopen ();
-    
+
   /* Pre-allocate a few structures.  */
 
   allocated_archive_names = 10;
This page took 0.022569 seconds and 4 git commands to generate.