]> Dogcows Code - chaz/tar/blobdiff - src/extract.c
tar: quote 'like this', not `like this'
[chaz/tar] / src / extract.c
index ecbde1a8c939a637d35e7addba297f7fbaac8951..0e499e5d4121649cc3c468ecb4d9aeda3aba811b 100644 (file)
@@ -271,15 +271,6 @@ set_mode (char const *file_name,
     }
 }
 
-/* Return true if A and B are the same birthtimes.
-   Unavailable birthtimes, which have negative tv_nsec members,
-   all compare equal to each other.  */
-static bool
-same_birthtime (struct timespec a, struct timespec b)
-{
-  return (a.tv_nsec == b.tv_nsec && (a.tv_nsec < 0 || a.tv_sec == b.tv_sec));
-}
-
 /* Check time after successfully setting FILE_NAME's time stamp to T.  */
 static void
 check_time (char const *file_name, struct timespec t)
@@ -651,9 +642,14 @@ maybe_recoverable (char *file_name, bool regular, bool *interdir_made)
 
       switch (old_files_option)
        {
-       case KEEP_OLD_FILES:
+       case SKIP_OLD_FILES:
+         WARNOPT (WARN_EXISTING_FILE,
+                  (0, 0, _("%s: skipping existing file"), file_name));
          return RECOVER_SKIP;
 
+       case KEEP_OLD_FILES:
+         return RECOVER_NO;
+
        case KEEP_NEWER_FILES:
          if (file_newer_p (file_name, stp, &current_stat_info))
            break;
@@ -891,7 +887,8 @@ open_output_file (char const *file_name, int typeflag, mode_t mode,
   /* If O_NOFOLLOW is needed but does not work, check for a symlink
      separately.  There's a race condition, but that cannot be avoided
      on hosts lacking O_NOFOLLOW.  */
-  if (! O_NOFOLLOW && overwriting_old_files && ! dereference_option)
+  if (! HAVE_WORKING_O_NOFOLLOW
+      && overwriting_old_files && ! dereference_option)
     {
       struct stat st;
       if (fstatat (chdir_fd, file_name, &st, AT_SYMLINK_NOFOLLOW) == 0
@@ -1002,7 +999,7 @@ extract_file (char *file_name, int typeflag)
        if (written > size)
          written = size;
        errno = 0;
-       count = full_write (fd, data_block->buffer, written);
+       count = blocking_write (fd, data_block->buffer, written);
        size -= written;
 
        set_next_block_after ((union block *)
@@ -1146,7 +1143,8 @@ extract_link (char *file_name, int typeflag)
              if (ds->change_dir == chdir_current
                  && ds->dev == st1.st_dev
                  && ds->ino == st1.st_ino
-                 && same_birthtime (ds->birthtime, get_stat_birthtime (&st1)))
+                 && (timespec_cmp (ds->birthtime, get_stat_birthtime (&st1))
+                     == 0))
                {
                  struct string_list *p =  xmalloc (offsetof (struct string_list, string)
                                                    + strlen (file_name) + 1);
@@ -1388,7 +1386,7 @@ prepare_to_extract (char const *file_name, int typeflag, tar_extractor_t *fun)
     default:
       WARNOPT (WARN_UNKNOWN_CAST,
               (0, 0,
-               _("%s: Unknown file type `%c', extracted as normal file"),
+               _("%s: Unknown file type '%c', extracted as normal file"),
                quotearg_colon (file_name), typeflag));
       *fun = extract_file;
     }
@@ -1512,7 +1510,7 @@ apply_delayed_links (void)
          if (fstatat (chdir_fd, source, &st, AT_SYMLINK_NOFOLLOW) == 0
              && st.st_dev == ds->dev
              && st.st_ino == ds->ino
-             && same_birthtime (get_stat_birthtime (&st), ds->birthtime))
+             && timespec_cmp (get_stat_birthtime (&st), ds->birthtime) == 0)
            {
              /* Unlink the placeholder, then create a hard link if possible,
                 a symbolic link otherwise.  */
This page took 0.026281 seconds and 4 git commands to generate.