+static FcChar8 *
+FcConfigInodeMatchFontDir (FcConfig *config, const FcChar8 *d)
+{
+ int n;
+ ino_t di;
+ dev_t dd;
+ struct stat s;
+
+ /* first we do string matches rather than file accesses */
+ /* FcStrSetMember doesn't tell us the index so that we can return
+ * the config-owned copy. */
+ for (n = 0; n < config->fontDirs->num; n++)
+ {
+ if (!FcStrCmp (config->fontDirs->strs[n], d))
+ return config->fontDirs->strs[n];
+ }
+
+ /* If this is a bottleneck, we can cache the fontDir inodes. */
+ if (stat ((char *)d, &s) == -1)
+ return 0;
+ di = s.st_ino; dd = s.st_dev;
+
+ for (n = 0; n < config->fontDirs->num; n++)
+ {
+ if (stat ((char *)config->fontDirs->strs[n], &s) == -1)
+ continue;
+ if (di == s.st_ino && dd == s.st_dev)
+ return config->fontDirs->strs[n];
+ }
+ return 0;
+}
+