]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Fix a handing of readdir_r on AIX. The meaning of the return value is
authorMichihiro NAKAJIMA <ggcueroad@gmail.com>
Sun, 14 Oct 2012 19:27:52 +0000 (04:27 +0900)
committerMichihiro NAKAJIMA <ggcueroad@gmail.com>
Sun, 14 Oct 2012 19:27:52 +0000 (04:27 +0900)
different from other posix systems.

libarchive/archive_read_disk_posix.c

index 8b50cc4262e9512ec01c5271ba80960e8d613c3b..2a9ab68c4f482aeea219c9f9b6605124ab50d7ed 100644 (file)
@@ -2339,11 +2339,21 @@ tree_dir_next_posix(struct tree *t)
 #endif /* HAVE_READDIR_R */
        }
        for (;;) {
+               errno = 0;
 #if defined(HAVE_READDIR_R)
                r = readdir_r(t->d, t->dirent, &t->de);
+#ifdef _AIX
+               /* Note: According to the man page, return value 9 indicates
+                * that the readdir_r was not successful and the error code
+                * is set to the global errno variable. And then if the end
+                * of directory entries was reached, the return value is 9
+                * and the third parameter is set to NULL and errno is
+                * unchanged. */
+               if (r == 9)
+                       r = errno;
+#endif /* _AIX */
                if (r != 0 || t->de == NULL) {
 #else
-               errno = 0;
                t->de = readdir(t->d);
                if (t->de == NULL) {
                        r = errno;