b6c903
Changes specific to RHEL-8:
b6c903
b6c903
- lstat64 is a macro, so undefine it first
b6c903
b6c903
commit f3629a4be82a393ff56646c388da2fda0101f557
b6c903
Author: Siddhesh Poyarekar <siddhesh@sourceware.org>
b6c903
Date:   Thu Jun 10 14:56:37 2021 +0530
b6c903
b6c903
    Handle DT_UNKNOWN in gconv-modules.d
b6c903
    
b6c903
    On filesystems that do not support dt_type, a regular file shows up as
b6c903
    DT_UNKNOWN.  Fall back to using lstat64 to read file properties in
b6c903
    such cases.
b6c903
    
b6c903
    Reviewed-by: DJ Delorie <dj@redhat.com>
b6c903
b6c903
diff --git a/iconv/gconv_parseconfdir.h b/iconv/gconv_parseconfdir.h
b6c903
index 3d4d58d4be10a250..ba9b3fd36d9e30f9 100644
b6c903
--- a/iconv/gconv_parseconfdir.h
b6c903
+++ b/iconv/gconv_parseconfdir.h
b6c903
@@ -32,6 +32,8 @@
b6c903
 # define readdir __readdir
b6c903
 # define closedir __closedir
b6c903
 # define mempcpy __mempcpy
b6c903
+# undef lstat64
b6c903
+# define lstat64 __lstat64
b6c903
 #endif
b6c903
 
b6c903
 /* Name of the file containing the module information in the directories
b6c903
@@ -138,7 +140,7 @@ gconv_parseconfdir (const char *dir, size_t dir_len)
b6c903
       struct dirent *ent;
b6c903
       while ((ent = readdir (confdir)) != NULL)
b6c903
 	{
b6c903
-	  if (ent->d_type != DT_REG)
b6c903
+	  if (ent->d_type != DT_REG && ent->d_type != DT_UNKNOWN)
b6c903
 	    continue;
b6c903
 
b6c903
 	  size_t len = strlen (ent->d_name);
b6c903
@@ -148,8 +150,14 @@ gconv_parseconfdir (const char *dir, size_t dir_len)
b6c903
 	      && strcmp (ent->d_name + len - strlen (suffix), suffix) == 0)
b6c903
 	    {
b6c903
 	      char *conf;
b6c903
+	      struct stat64 st;
b6c903
 	      if (asprintf (&conf, "%s/%s", buf, ent->d_name) < 0)
b6c903
 		continue;
b6c903
+	      if (ent->d_type == DT_UNKNOWN
b6c903
+		  && (lstat64 (conf, &st) == -1
b6c903
+		      || !S_ISREG (st.st_mode)))
b6c903
+		continue;
b6c903
+
b6c903
 	      found |= read_conf_file (conf, dir, dir_len);
b6c903
 	      free (conf);
b6c903
 	    }