commit:     0cd1766c6aac6965666797dd875b1fdc0ea91b47
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Sat Nov 12 17:16:36 2016 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Sat Nov 12 17:16:36 2016 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=0cd1766c

qcache: handle DT_UNKNOWN and cases where DT_xxx are not available #580354

URL: https://bugs.gentoo.org/580354
Reported-by: Fabian Groffen <grobian <AT> gentoo.org>

 qcache.c | 22 ++++++++++++++++++++--
 1 file changed, 20 insertions(+), 2 deletions(-)

diff --git a/qcache.c b/qcache.c
index 222c8ae..535d7a2 100644
--- a/qcache.c
+++ b/qcache.c
@@ -750,13 +750,31 @@ void qcache_stats(qcache_data *data)
 
                xasprintf(&catpath, "%s/dep/%s", portedb, data->overlay);
                dir = opendir(catpath);
-               while ((de = readdir(dir)))
-                       if (de->d_type == DT_DIR && de->d_name[0] != '.') {
+               while ((de = readdir(dir))) {
+                       /* Look for all the directories in this path. */
+#ifdef DT_UNKNOWN
+                       if (de->d_type == DT_UNKNOWN)
+#endif
+                       {
+                               struct stat s;
+                               if (lstat(de->d_name, &s))
+                                       continue;
+                               if (!S_ISDIR(s.st_mode))
+                                       continue;
+                       }
+
+#ifdef DT_DIR
+                       if (de->d_type != DT_DIR)
+                               continue;
+#endif
+
+                       if (de->d_name[0] != '.') {
                                bool ok;
                                allcats = add_set_unique(de->d_name, allcats, 
&ok);
                                if (ok)
                                        ++numcat;
                        }
+               }
                closedir(dir);
                free(catpath);
 

Reply via email to