Deal correctly with changing FC_CACHE_MAGIC.

This commit is contained in:
Patrick Lam 2006-02-16 17:50:04 +00:00
parent d2c0102944
commit 8c0d692125
2 changed files with 22 additions and 0 deletions

View File

@ -1,3 +1,8 @@
2006-02-16 Patrick Lam <plam@mit.edu>
* src/fccache.c (FcDirCacheHasCurrentArch):
Deal correctly with changing FC_CACHE_MAGIC.
2006-02-16 Patrick Lam <plam@mit.edu> 2006-02-16 Patrick Lam <plam@mit.edu>
* fc-cache/fc-cache.c (usage, scanDirs, main): * fc-cache/fc-cache.c (usage, scanDirs, main):

View File

@ -759,6 +759,7 @@ FcDirCacheHasCurrentArch (const FcChar8 *dir)
int fd; int fd;
off_t current_arch_start; off_t current_arch_start;
char *current_arch_machine_name; char *current_arch_machine_name;
FcCache metadata;
fd = FcDirCacheOpen (dir); fd = FcDirCacheOpen (dir);
if (fd < 0) if (fd < 0)
@ -766,6 +767,22 @@ FcDirCacheHasCurrentArch (const FcChar8 *dir)
current_arch_machine_name = FcCacheMachineSignature(); current_arch_machine_name = FcCacheMachineSignature();
current_arch_start = FcCacheSkipToArch(fd, current_arch_machine_name); current_arch_start = FcCacheSkipToArch(fd, current_arch_machine_name);
if (current_arch_start >= 0)
{
if (read(fd, &metadata, sizeof(FcCache)) != sizeof(FcCache))
{
close (fd);
return FcFalse;
}
if (metadata.magic != FC_CACHE_MAGIC)
{
close (fd);
return FcFalse;
}
}
close (fd); close (fd);
if (current_arch_start < 0) if (current_arch_start < 0)