From: Siddhesh Poyarekar <siddhesh@sourceware.org>
To: libc-alpha@sourceware.org
Subject: [PATCH v2 5/6] Handle DT_UNKNOWN in gconv-modules.d
Date: Tue, 22 Jun 2021 10:42:01 +0530 [thread overview]
Message-ID: <20210622051202.4155709-6-siddhesh@sourceware.org> (raw)
In-Reply-To: <20210622051202.4155709-1-siddhesh@sourceware.org>
On filesystems that do not support dt_type, a regular file shows up as
DT_UNKNOWN. Fall back to using lstat64 to read file properties in
such cases.
Reviewed-by: DJ Delorie <dj@redhat.com>
---
iconv/gconv_parseconfdir.h | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/iconv/gconv_parseconfdir.h b/iconv/gconv_parseconfdir.h
index 3d4d58d4be..e73ea0ff5c 100644
--- a/iconv/gconv_parseconfdir.h
+++ b/iconv/gconv_parseconfdir.h
@@ -32,6 +32,7 @@
# define readdir __readdir
# define closedir __closedir
# define mempcpy __mempcpy
+# define lstat64 __lstat64
#endif
/* Name of the file containing the module information in the directories
@@ -138,7 +139,7 @@ gconv_parseconfdir (const char *dir, size_t dir_len)
struct dirent *ent;
while ((ent = readdir (confdir)) != NULL)
{
- if (ent->d_type != DT_REG)
+ if (ent->d_type != DT_REG && ent->d_type != DT_UNKNOWN)
continue;
size_t len = strlen (ent->d_name);
@@ -148,8 +149,14 @@ gconv_parseconfdir (const char *dir, size_t dir_len)
&& strcmp (ent->d_name + len - strlen (suffix), suffix) == 0)
{
char *conf;
+ struct stat64 st;
if (asprintf (&conf, "%s/%s", buf, ent->d_name) < 0)
continue;
+ if (ent->d_type == DT_UNKNOWN
+ && (lstat64 (conf, &st) == -1
+ || !S_ISREG (st.st_mode)))
+ continue;
+
found |= read_conf_file (conf, dir, dir_len);
free (conf);
}
--
2.31.1
next prev parent reply other threads:[~2021-06-22 5:12 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-22 5:11 [PATCH v2 0/6] gconv configuration parsing cleanups Siddhesh Poyarekar
2021-06-22 5:11 ` [PATCH v2 1/6] iconv: Remove alloca use in gconv-modules configuration parsing Siddhesh Poyarekar
2021-06-22 5:11 ` [PATCH v2 2/6] gconv_conf: Remove unused variables Siddhesh Poyarekar
2021-06-22 5:11 ` [PATCH v2 3/6] gconv_conf: Split out configuration file processing Siddhesh Poyarekar
2021-06-22 5:12 ` [PATCH v2 4/6] iconvconfig: Use common gconv module parsing function Siddhesh Poyarekar
2021-06-22 5:27 ` DJ Delorie
2021-06-22 5:12 ` Siddhesh Poyarekar [this message]
2021-06-22 5:12 ` [PATCH v2 6/6] Add NEWS item for gconv-modules.d change Siddhesh Poyarekar
2021-06-23 3:10 ` DJ Delorie
2021-06-24 8:46 ` [PATCH v2 0/6] gconv configuration parsing cleanups Andreas Schwab
2021-06-24 9:18 ` Siddhesh Poyarekar
2021-06-24 9:23 ` Andreas Schwab
2021-06-24 15:33 ` Siddhesh Poyarekar
2021-06-24 15:46 ` Andreas Schwab
2021-06-24 15:57 ` Siddhesh Poyarekar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210622051202.4155709-6-siddhesh@sourceware.org \
--to=siddhesh@sourceware.org \
--cc=libc-alpha@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).