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