Fallback to lstat() in case the filesystem doesn't support d_type in struct dirent
This commit is contained in:
parent
e310d2fac2
commit
39a2f1e8f9
12
src/fcstat.c
12
src/fcstat.c
|
@ -186,10 +186,8 @@ FcDirChecksum (const FcChar8 *dir, time_t *checksum)
|
||||||
struct Adler32 ctx;
|
struct Adler32 ctx;
|
||||||
struct dirent **files;
|
struct dirent **files;
|
||||||
int n;
|
int n;
|
||||||
#ifndef HAVE_STRUCT_DIRENT_D_TYPE
|
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
size_t len = strlen ((const char *)dir);
|
size_t len = strlen ((const char *)dir);
|
||||||
#endif
|
|
||||||
|
|
||||||
Adler32Init (&ctx);
|
Adler32Init (&ctx);
|
||||||
|
|
||||||
|
@ -210,7 +208,9 @@ FcDirChecksum (const FcChar8 *dir, time_t *checksum)
|
||||||
|
|
||||||
#ifdef HAVE_STRUCT_DIRENT_D_TYPE
|
#ifdef HAVE_STRUCT_DIRENT_D_TYPE
|
||||||
dtype = files[n]->d_type;
|
dtype = files[n]->d_type;
|
||||||
#else
|
if (dtype == DT_UNKNOWN)
|
||||||
|
{
|
||||||
|
#endif
|
||||||
struct stat statb;
|
struct stat statb;
|
||||||
char f[PATH_MAX + 1];
|
char f[PATH_MAX + 1];
|
||||||
|
|
||||||
|
@ -227,20 +227,18 @@ FcDirChecksum (const FcChar8 *dir, time_t *checksum)
|
||||||
goto bail;
|
goto bail;
|
||||||
|
|
||||||
dtype = statb.st_mode;
|
dtype = statb.st_mode;
|
||||||
|
#ifdef HAVE_STRUCT_DIRENT_D_TYPE
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
Adler32Update (&ctx, files[n]->d_name, dlen + 1);
|
Adler32Update (&ctx, files[n]->d_name, dlen + 1);
|
||||||
Adler32Update (&ctx, (char *)&dtype, sizeof (int));
|
Adler32Update (&ctx, (char *)&dtype, sizeof (int));
|
||||||
|
|
||||||
#ifndef HAVE_STRUCT_DIRENT_D_TYPE
|
|
||||||
bail:
|
bail:
|
||||||
#endif
|
|
||||||
free (files[n]);
|
free (files[n]);
|
||||||
}
|
}
|
||||||
free (files);
|
free (files);
|
||||||
#ifndef HAVE_STRUCT_DIRENT_D_TYPE
|
|
||||||
if (ret == -1)
|
if (ret == -1)
|
||||||
return -1;
|
return -1;
|
||||||
#endif
|
|
||||||
|
|
||||||
*checksum = Adler32Finish (&ctx);
|
*checksum = Adler32Finish (&ctx);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue