diff options
authorDave Airlie <>2009-10-13 10:15:00 +1000
committerKeith Packard <>2009-11-09 08:24:39 -0800
commitd85ab6b6483d6ca7d9d22298d05ed1fa3076b042 (patch)
parenta5e59230de3abafda9cd9d571cea192897155a14 (diff)
loader: actually stat something that has some chance of existing. (v2)
FindModuleInSubdir seems to expect a / at the end of the subdir its finding for, so we add the / early, the stat will fail if its not a subdir, I'm leaving the S_ISDIR in just in case there is another reason it could return 0. This does look a bit silly in strace but it seems to work fine. I have a very intermittent issue where drivers loses its / that I've been seeing on/off for a while, this may or may not fix it. Signed-off-by: Dave Airlie <> Reviewed-by: Julien Cristau <> Signed-off-by: Keith Packard <>
1 files changed, 5 insertions, 2 deletions
diff --git a/hw/xfree86/loader/loadmod.c b/hw/xfree86/loader/loadmod.c
index 0b220f1b6..5b175a546 100644
--- a/hw/xfree86/loader/loadmod.c
+++ b/hw/xfree86/loader/loadmod.c
@@ -399,8 +399,11 @@ FindModuleInSubdir(const char *dirpath, const char *module)
while ((direntry = readdir(dir))) {
if (direntry->d_name[0] == '.')
- if ((stat(direntry->d_name, &stat_buf) == 0) && S_ISDIR(stat_buf.st_mode)) {
- snprintf(tmpBuf, PATH_MAX, "%s/%s", dirpath, direntry->d_name);
+ snprintf(tmpBuf, PATH_MAX, "%s%s/", dirpath, direntry->d_name);
+ /* the stat with the appended / fails for normal files,
+ and works for sub dirs fine, looks a bit strange in strace
+ but does seem to work */
+ if ((stat(tmpBuf, &stat_buf) == 0) && S_ISDIR(stat_buf.st_mode)) {
if ((ret = FindModuleInSubdir(tmpBuf, module)))