Example (using a x86_64 machine which has a 64-bit fc-cache *and* a 32bit fc-cache called "fc-cache32"): mfabian@magellan:~$ uname -a Linux magellan 2.6.18-rc4-2-default #1 Tue Aug 8 09:58:49 UTC 2006 x86_64 x86_64 x86_64 GNU/Linux mfabian@magellan:~$ Start with no caches at all: mfabian@magellan:~$ ls /var/cache/fontconfig/ mfabian@magellan:~$ ls .fontconfig mfabian@magellan:~$ Run the 64-bit version of fc-cache: mfabian@magellan:~$ fc-cache -v /usr/share/fonts/truetype /usr/share/fonts/truetype: caching, 911 fonts, 0 dirs /var/cache/fontconfig: not cleaning unwritable cache directory /home/mfabian/.fontconfig: cleaning cache directory fc-cache: succeeded mfabian@magellan:~$ The 64-bit cache has been created: mfabian@magellan:~$ ls /var/cache/fontconfig/ mfabian@magellan:~$ ls .fontconfig 7ef2298fde41cc6eeb7af42e48b7d293-x86-64.cache-2 mfabian@magellan:~$ Now run the 32-bit version of fc-cache: mfabian@magellan:~$ fc-cache32 -v /usr/share/fonts/truetype /usr/share/fonts/truetype: caching, 911 fonts, 0 dirs /var/cache/fontconfig: not cleaning unwritable cache directory /home/mfabian/.fontconfig: cleaning cache directory /home/mfabian/.fontconfig: 7ef2298fde41cc6eeb7af42e48b7d293-x86-64.cache-2: missing directory: fc-cache32: succeeded mfabian@magellan:~$ There was a strange error message at the end. And the 64-bit cache is gone now: mfabian@magellan:~$ ls /var/cache/fontconfig/ mfabian@magellan:~$ ls .fontconfig 7ef2298fde41cc6eeb7af42e48b7d293-x86.cache-2 mfabian@magellan:~$ That''s not right, fc-cache should not touch the cache files for different architectures. -- Mike FABIAN <mfabian@suse.de> http://www.suse.de/~mfabian
Mike FABIAN
2006-Oct-24 08:36 UTC
[Fontconfig] Patch (was: fc-cache for x86 deletes caches for x86_64)
Mike FABIAN <mfabian@suse.de> :> Now run the 32-bit version of fc-cache: > > mfabian@magellan:~$ fc-cache32 -v /usr/share/fonts/truetype > /usr/share/fonts/truetype: caching, 911 fonts, 0 dirs > /var/cache/fontconfig: not cleaning unwritable cache directory > /home/mfabian/.fontconfig: cleaning cache directory > /home/mfabian/.fontconfig: 7ef2298fde41cc6eeb7af42e48b7d293-x86-64.cache-2: missing directory: fc-cache32: succeeded > mfabian@magellan:~$ > > There was a strange error message at the end. > And the 64-bit cache is gone now: > > mfabian@magellan:~$ ls /var/cache/fontconfig/ > mfabian@magellan:~$ ls .fontconfig > 7ef2298fde41cc6eeb7af42e48b7d293-x86.cache-2 > mfabian@magellan:~$ > > That''s not right, fc-cache should not touch the cache files > for different architectures.The reason why fc-cache32 deletes the x86-64 cache files but the 64 bit fc-cache doesn''t delete the x86 cache files is as follows: In case of fc-cache32, line 313 cache = FcDirCacheLoadFile (file_name, &file_stat); in fc-cache.c happens to be successful. But then fc-cache32 cannot read the directory out of the x86-64 cache file i.e. target_dir = FcCacheDir (cache); remove = FcFalse; if (stat ((char *) target_dir, &target_stat) < 0) { if (verbose) printf ("%s: %s: missing directory: %s \n", dir, ent->d_name, target_dir); remove = FcTrue; } leads to the removal of the x86-64 cache file. In case of the 64 bit fc-cache, cache = FcDirCacheLoadFile (file_name, &file_stat); already fails because of line 467 in fccache.c (function FcDirCacheMapFd ()): cache->size != fd_stat->st_size || cache->size is of type intptr_t which is 8 bytes on x86-64 but only 4 bytes on x86. Therefore, the 64 bit fc-cache reads 4 bytes containing the file size plus another 4 bytes of junk and interprets this as the file size: struct _FcCache { int magic; /* FC_CACHE_MAGIC_MMAP or FC_CACHE_ALLOC */ int version; /* FC_CACHE_CONTENT_VERSION */ intptr_t size; /* size of file */ intptr_t dir; /* offset to dir name */ intptr_t dirs; /* offset to subdirs */ int dirs_count; /* number of subdir strings */ intptr_t set; /* offset to font set */ }; But even then one gets the annoying message fprintf (stderr, "%s: invalid cache file: %s\n", dir, ent->d_name); for each -x86.cache-2 file. This makes no sense because it is OK that cache files for other architectures are there. I tried to fix the problem with the attached patch which seems to work for me. -------------- next part -------------- A non-text attachment was scrubbed... Name: do-not-clean-cache-files-for-different-architectures.patch Type: text/x-patch Size: 729 bytes Desc: not available Url : http://lists.freedesktop.org/archives/fontconfig/attachments/20061024/20867f3d/do-not-clean-cache-files-for-different-architectures.bin -------------- next part -------------- -- Mike FABIAN <mfabian@suse.de> http://www.suse.de/~mfabian
Keith Packard
2006-Oct-24 10:07 UTC
[Fontconfig] Patch (was: fc-cache for x86 deletes caches for x86_64)
On Tue, 2006-10-24 at 17:36 +0200, Mike FABIAN wrote:> I tried to fix the problem with the attached patch which > seems to work for me.Yes, that''s obviously the right plan; ignore files which aren''t of the right form. Instead of using strstr, it would be better to just compare the end of the filename against the provided pattern. -- keith.packard@intel.com -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 189 bytes Desc: This is a digitally signed message part Url : http://lists.freedesktop.org/archives/fontconfig/attachments/20061024/2ade0413/attachment.pgp
Mike FABIAN
2006-Oct-27 05:40 UTC
[Fontconfig] Re: Patch (was: fc-cache for x86 deletes caches for x86_64)
Keith Packard <keithp@keithp.com> ????????:> On Tue, 2006-10-24 at 17:36 +0200, Mike FABIAN wrote: > >> I tried to fix the problem with the attached patch which >> seems to work for me. > > Yes, that''s obviously the right plan; ignore files which aren''t of the > right form. Instead of using strstr, it would be better to just compare > the end of the filename against the provided pattern.Here is an improved patch which does this. -------------- next part -------------- A non-text attachment was scrubbed... Name: do-not-clean-cache-files-for-different-architectures.patch Type: text/x-patch Size: 955 bytes Desc: not available Url : http://lists.freedesktop.org/archives/fontconfig/attachments/20061027/8546d44a/do-not-clean-cache-files-for-different-architectures.bin -------------- next part -------------- -- Mike FABIAN <mfabian@suse.de> http://www.suse.de/~mfabian ?????????????
Keith Packard
2006-Oct-27 10:29 UTC
[Fontconfig] Re: Patch (was: fc-cache for x86 deletes caches for x86_64)
On Fri, 2006-10-27 at 14:40 +0200, Mike FABIAN wrote:> Keith Packard <keithp@keithp.com> ????????: > > > On Tue, 2006-10-24 at 17:36 +0200, Mike FABIAN wrote: > > > >> I tried to fix the problem with the attached patch which > >> seems to work for me. > > > > Yes, that''s obviously the right plan; ignore files which aren''t of the > > right form. Instead of using strstr, it would be better to just compare > > the end of the filename against the provided pattern. > > Here is an improved patch which does this.Thanks muchly; it''s pushed to master. -- keith.packard@intel.com -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 189 bytes Desc: This is a digitally signed message part Url : http://lists.freedesktop.org/archives/fontconfig/attachments/20061027/c3d3b2fd/attachment.pgp