]> Dogcows Code - chaz/tar/commitdiff
tar: don't worry about fdopendir closing its argument
authorPaul Eggert <eggert@cs.ucla.edu>
Mon, 13 Sep 2010 20:12:54 +0000 (13:12 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Mon, 13 Sep 2010 20:13:08 +0000 (13:13 -0700)
* NEWS: Don't mention dirfd; no longer needed.
* gnulib.modules: Remove dirfd.
* src/create.c (get_directory_entries): Remove the code dealing
with dirfd failures, as the new fdopendir replacement doesn't
close its argument so we don't need to call dirfd.  See
<http://lists.gnu.org/archive/html/bug-gnulib/2010-09/msg00208.html>
and gnulib commit 970c9038e4cca46e1b037ae0a6d574dfae6a7327.

NEWS
gnulib.modules
src/create.c

diff --git a/NEWS b/NEWS
index db7cae24157e29efde1d0802ffd6b8e9638cb29c..ae80441605b1dcd939198920c1d40ac25dcc2773 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -18,7 +18,7 @@ modified while tar is creating an archive.  In the new approach, tar
 maintains a cache of file descriptors to directories, so it uses more
 file descriptors than before, but it adjusts to system limits on
 the number of file descriptors.  The new checks are implemented via
-the openat, dirfd, fdopendir, fstatat, and readlinkat calls
+the openat, fdopendir, fstatat, and readlinkat calls
 standardized by POSIX.1-2008.  On an older system where these calls do
 not exist or do not return useful results, tar emulates the calls at
 some cost in efficiency and reliability.
index 653092398cd31eccd540d18e4e2b53259413c48a..a595d90288022d49427528d8ee3538772e0b9227 100644 (file)
@@ -8,7 +8,6 @@ argp-version-etc
 backupfile
 closeout
 configmake
-dirfd
 dirname
 error
 exclude
index 5e2171b561917a74c2bde424a9eb7e0648c970a0..9dc928d347839ad4c8bc63f59cd790c5d0fef341 100644 (file)
@@ -1263,49 +1263,10 @@ open_failure_recover (struct tar_stat_info const *dir)
 char *
 get_directory_entries (struct tar_stat_info *st)
 {
-  DIR *dirstream;
-  while (! (dirstream = fdopendir (st->fd)) && open_failure_recover (st))
-    continue;
-
-  if (! dirstream)
-    return 0;
-  else
-    {
-      char *entries = streamsavedir (dirstream);
-      int streamsavedir_errno = errno;
-
-      int fd = dirfd (dirstream);
-      if (fd < 0)
-       {
-         /* The dirent.h implementation doesn't use file descriptors
-            for directory streams, so open the directory again.  */
-         char const *name = st->orig_file_name;
-         if (closedir (dirstream) != 0)
-           close_diag (name);
-         dirstream = 0;
-         fd = subfile_open (st->parent,
-                            st->parent ? last_component (name) : name,
-                            open_searchdir_flags);
-         if (fd < 0)
-           fd = - errno;
-         else
-           {
-             struct stat dirst;
-             if (! (fstat (fd, &dirst) == 0
-                    && st->stat.st_ino == dirst.st_ino
-                    && st->stat.st_dev == dirst.st_dev))
-               {
-                 close (fd);
-                 fd = - IMPOSTOR_ERRNO;
-               }
-           }
-       }
-
-      st->fd = fd;
-      st->dirstream = dirstream;
-      errno = streamsavedir_errno;
-      return entries;
-    }
+  while (! (st->dirstream = fdopendir (st->fd)))
+    if (! open_failure_recover (st))
+      return 0;
+  return streamsavedir (st->dirstream);
 }
 
 /* Dump the directory ST.  Return true if successful, false (emitting
This page took 0.027856 seconds and 4 git commands to generate.