[Mesa-dev] [PATCH] util/disk_cache: use stat() to check if entry is a directory

Emil Velikov emil.l.velikov at gmail.com
Fri Feb 10 12:19:26 UTC 2017


On 9 February 2017 at 23:05, Timothy Arceri <tarceri at itsqueeze.com> wrote:
> d_type is not supported on all systems.
>
> Tested-by: Vinson Lee <vlee at freedesktop.org>
> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=97967
CC: "13.0 17.0" <mesa-stable at lists.freedesktop.org>
Reviewed-by: Emil Velikov <emil.velikov at collabora.com>

> @@ -473,7 +474,7 @@ choose_random_file_matching(const char *dir_path,
>        entry = readdir(dir);
>        if (entry == NULL)
>           break;
> -      if (! predicate(entry))
> +      if (!predicate(entry, dir_path))
>           continue;
>        if (count == victim)
>           break;
Thinking out loud:
We don't need to walk over the directory (cut down the
asprintf/stat/strcmp) twice if we pick a pseudo-random file ;-)

-Emil


More information about the mesa-dev mailing list