util: Make xmlconfig.c build on Solaris without d_type in dirent (v2)
authorAlan Coopersmith <alan.coopersmith@oracle.com>
Fri, 5 Oct 2018 23:34:35 +0000 (16:34 -0700)
committerIan Romanick <ian.d.romanick@intel.com>
Sat, 6 Oct 2018 00:30:45 +0000 (17:30 -0700)
v2: check for lstat() failing

Fixes: 04bdbbcab3c "xmlconfig: read more config files from drirc.d/"
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Roland Mainz <roland.mainz@nrubsig.org>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
src/util/xmlconfig.c

index 5264f2598b4f06e7a6ffaba9409eaa1d8968ab67..5907c68012e774c4c20551ba0ec30c7a2fa7f979 100644 (file)
@@ -938,8 +938,16 @@ parseOneConfigFile(struct OptConfData *data, const char *filename)
 static int
 scandir_filter(const struct dirent *ent)
 {
+#ifndef DT_REG /* systems without d_type in dirent results */
+    struct stat st;
+
+    if ((lstat(ent->d_name, &st) != 0) ||
+        (!S_ISREG(st.st_mode) && !S_ISLNK(st.st_mode)))
+       return 0;
+#else
     if (ent->d_type != DT_REG && ent->d_type != DT_LNK)
        return 0;
+#endif
 
     if (fnmatch("*.conf", ent->d_name, 0))
        return 0;