[Fontconfig] Re: fix for unaligned accesses

Mike FABIAN mfabian at suse.de
Fri Jan 20 09:36:37 PST 2006

Patrick Lam <plam at MIT.EDU> さんは書きました:

> Mike FABIAN wrote:
>> Patch by Andreas Schwab <schwab at suse.de>.
>> See also:
>> http://bugzilla.novell.com/show_bug.cgi?id=142215
> Looks good, I've committed it.
> Are there any of the /var/cache/fontconfig bugs still outstanding?  I'll
> try to take a look at any leftover ones there sooner or later, if folks
> let me know what's up...

I think there are still problems with the normalizing of the font
directory names.

I posted a patch to this list recently to fix the problem that

    fc-cache /usr/share/fonts
    fc-cache /usr/share/fonts/
    cd /usr/share/fonts; fc-cache .

generate different cache files, but this patch had the problem that
it neede to call FcInitLoadConfigAndFonts () instead of
FcInitLoadConfig () to be able to use FcConfigNormalizeFontDir().

But this has the severe disadvantage that  FcInitLoadConfigAndFonts ()
is very expensive, therefore this is not a good solution.

Frederic Crozat's approach using realpath () worked much better.

But you said realpath () cannot be used because it appears to be
problematic and not portable according to its man-page.

Yesterday Rüdiger Oertel <ro at suse.de> had the idea to use the inodes
and device ids of the directory to cache to create the md5sums for the
file names of the cache files and Dirk Mueller <dmueller at suse.de> made
a patch to try this approach.

This idea seems to have the problem that for some file systems
inodes may change when mounting the same file system again.
For example with a vfat file system:

    root at magellan:~# mount | grep mnt
    /tmp/image on /mnt type vfat (rw,loop=/dev/loop0)
    root at magellan:~# ls -i /mnt
    1157 a*  1158 b*  1159 c*  1160 d*  1161 e*  1162 f*  1163 g*  1164 h*
    root at magellan:~# umount /mnt 
    root at magellan:~# mount -o loop  /tmp/image  /mnt
    root at magellan:~# ls -i /mnt
    1173 a*  1174 b*  1175 c*  1176 d*  1177 e*  1178 f*  1179 g*  1180 h*
    root at magellan:~# 

The inodes were different when mounting the file system the second

I.e. if one has a windows system with a vfat partition and adds the
font directory of the windows system to the search path of fontconfig,
the caches in /var/cache/fontconfig will probably appear to be missing
after each boot just because the inodes on the windows partition have

Maybe using something like realpath() is the best solution after all.

Takashi Iwai <tiwai at suse.de> had the idea that realpath can be
emulated portably using chdir() and getcwd().

That sounds like a solution which really could work portably.

Mike FABIAN   <mfabian at suse.de>   http://www.suse.de/~mfabian

More information about the Fontconfig mailing list