bug-tar
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bug-tar] Problem with fstatat on AIX 7.1


From: Paul Eggert
Subject: Re: [Bug-tar] Problem with fstatat on AIX 7.1
Date: Sun, 04 Sep 2011 10:00:31 -0700
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.21) Gecko/20110831 Thunderbird/3.1.13

Thanks.  A few things.  First, the truss output says
that 'tar' is using 'kopen' (whatever that is) rather than openat.
But the config.log you sent for an earlier build suggests that
tar is using openat.  Can you please check this, by sending the
config.log for the last 'tar' you built most recently?

Second, can you please compile and send the truss output of the following
program so that we can see what the truss output for a true
'openat' looks like?

  #define _LARGE_FILES 1
  #include <fcntl.h>

  int
  main (void)
  {
    return openat (AT_FDCWD, ".", O_RDONLY) < 0;
  }

Third, the 'truss' output is confusing because it's being intermingled
with internationalization stuff.  For now let's try to disable this by setting
LC_ALL=C in your environment (in the shell, "LC_ALL=C; export LC_ALL")
before running the tests.  (I'll suggest the next test below.)

Fourth and finally, what 'tar' is supposed to do is something like this:

957   fstatat(9, "X", {st_mode=S_IFREG|0644, st_size=2, ...}, 
AT_SYMLINK_NOFOLLOW) = 0                 
957   openat(9, "X", O_RDONLY|O_NOCTTY|O_NONBLOCK|O_NOFOLLOW|O_CLOEXEC) = -1 
EMFILE (Too many open files)
957   close(4)                          = 0
957   openat(9, "X", O_RDONLY|O_NOCTTY|O_NONBLOCK|O_NOFOLLOW|O_CLOEXEC) = 4

That is, it should be getting the status of the file "X" relative to the
directory with file descriptor 9, then opening "X", then discovering that
it's out of file descriptors, then closing a file descriptor 4 that it's
caching but can reopen later, then opening "X" again, this time successfully.

But here's what the corresponding truss output says:

11665724:       26149233: statx("X", 0x30003078, 176, 021)      = 0
11665724:       26149233: _getpid()                             = 11665724
11665724:       26149233: kopen("X", O_RDONLY|O_LARGEFILE)      Err#24 EMFILE
11665724:       26149233: _getpid()                             = 11665724
11665724:       26149233: lseek(4, 0, 1)                        = 4096
11665724:       26149233: kwrite(2, " t a r :  ", 5)            = 5
11665724:       26149233: access("/usr/lib/nls/msg/en_US/libc.cat", 0) = 0
11665724:       26149233: _getpid()                             = 11665724
11665724:       26149233: kopen("/usr/lib/nls/msg/en_US/libc.cat", O_RDONLY) 
Err#24 EMFILE

Here, file descriptor 4 is a message-catalog file descriptor, which is
sort of getting in the way, but it appears that 'tar' is simply giving up
when EMFILE occurs.  Let's try to figure that out, by applying the following
patch to the latest 'tar' distribution I sent you, and seeing how the test
does with that.  Please run this with LC_ALL=C in your environment.

Thanks.

diff --git a/src/create.c b/src/create.c
index 9839e1f..47af317 100644
--- a/src/create.c
+++ b/src/create.c
@@ -1251,18 +1251,27 @@ ensure_slash (char **pstr)
 static bool
 open_failure_recover (struct tar_stat_info const *dir)
 {
+  int e = errno;
+  fprintf (stderr, "open_failure_recover called\n");
   if (errno == EMFILE && dir && dir->parent)
     {
       struct tar_stat_info *p;
       for (p = dir->parent->parent; p; p = p->parent)
+       {
+       fprintf (stderr, "p=%p, p->fd=%d, p->parent=%p, p->parent->fd=%d\n",
+                p, p->fd, p->parent, p->parent ? p->parent->fd : -999999);
        if (0 < p->fd && (! p->parent || p->parent->fd <= 0))
          {
            tar_stat_close (p);
+           fprintf (stderr, "open_failure_recover succeeded\n");
            return true;
          }
+       }
       errno = EMFILE;
     }
 
+  fprintf (stderr, "open_failure_recover failed\n");
+  errno = e;
   return false;
 }
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]