mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 09:38:07 +02:00
util/disk_cache: make MESA_DISK_CACHE_READ_ONLY_FOZ_DBS a relative path
Rather than passing in full paths this changes things so that we can just pass in filenames relative to the current cache directory. Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9279>
This commit is contained in:
parent
a8423eb732
commit
9d1ef1595c
5 changed files with 12 additions and 17 deletions
|
|
@ -112,7 +112,7 @@ disk_cache_create(const char *gpu_name, const char *driver_id,
|
|||
goto path_fail;
|
||||
|
||||
if (env_var_as_boolean("MESA_DISK_CACHE_SINGLE_FILE", false)) {
|
||||
if (!disk_cache_load_cache_index(local, cache, path))
|
||||
if (!disk_cache_load_cache_index(local, cache))
|
||||
goto path_fail;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -953,15 +953,10 @@ disk_cache_write_item_to_disk_foz(struct disk_cache_put_job *dc_job)
|
|||
}
|
||||
|
||||
bool
|
||||
disk_cache_load_cache_index(void *mem_ctx, struct disk_cache *cache,
|
||||
char *path)
|
||||
disk_cache_load_cache_index(void *mem_ctx, struct disk_cache *cache)
|
||||
{
|
||||
path = ralloc_asprintf(mem_ctx, "%s/foz_cache", cache->path);
|
||||
if (path == NULL)
|
||||
return false;
|
||||
|
||||
/* Load cache index into a hash map (from fossilise files) */
|
||||
return foz_prepare(&cache->foz_db, path);
|
||||
return foz_prepare(&cache->foz_db, cache->path);
|
||||
}
|
||||
|
||||
bool
|
||||
|
|
|
|||
|
|
@ -124,8 +124,7 @@ bool
|
|||
disk_cache_enabled(void);
|
||||
|
||||
bool
|
||||
disk_cache_load_cache_index(void *mem_ctx, struct disk_cache *cache,
|
||||
char *path);
|
||||
disk_cache_load_cache_index(void *mem_ctx, struct disk_cache *cache);
|
||||
|
||||
bool
|
||||
disk_cache_mmap_cache_index(void *mem_ctx, struct disk_cache *cache,
|
||||
|
|
|
|||
|
|
@ -97,13 +97,13 @@ check_files_opened_successfully(FILE *file, FILE *db_idx)
|
|||
}
|
||||
|
||||
static bool
|
||||
create_foz_db_filenames(char *base_filename, char **filename,
|
||||
create_foz_db_filenames(char *cache_path, char *name, char **filename,
|
||||
char **idx_filename)
|
||||
{
|
||||
if (asprintf(filename, "%s.foz", base_filename) == -1)
|
||||
if (asprintf(filename, "%s/%s.foz", cache_path, name) == -1)
|
||||
return false;
|
||||
|
||||
if (asprintf(idx_filename, "%s_idx.foz", base_filename) == -1) {
|
||||
if (asprintf(idx_filename, "%s/%s_idx.foz", cache_path, name) == -1) {
|
||||
free(*filename);
|
||||
return false;
|
||||
}
|
||||
|
|
@ -232,11 +232,11 @@ fail:
|
|||
* read cache entries from the foz db containing the actual cache entries.
|
||||
*/
|
||||
bool
|
||||
foz_prepare(struct foz_db *foz_db, char *base_filename)
|
||||
foz_prepare(struct foz_db *foz_db, char *cache_path)
|
||||
{
|
||||
char *filename = NULL;
|
||||
char *idx_filename = NULL;
|
||||
if (!create_foz_db_filenames(base_filename, &filename, &idx_filename))
|
||||
if (!create_foz_db_filenames(cache_path, "foz_cache", &filename, &idx_filename))
|
||||
return false;
|
||||
|
||||
/* Open the default foz dbs for read/write. If the files didn't already exist
|
||||
|
|
@ -269,7 +269,8 @@ foz_prepare(struct foz_db *foz_db, char *base_filename)
|
|||
|
||||
filename = NULL;
|
||||
idx_filename = NULL;
|
||||
if (!create_foz_db_filenames(foz_db_filename, &filename, &idx_filename)) {
|
||||
if (!create_foz_db_filenames(cache_path, foz_db_filename, &filename,
|
||||
&idx_filename)) {
|
||||
free(foz_db_filename);
|
||||
continue; /* Ignore invalid user provided filename and continue */
|
||||
}
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ struct foz_db {
|
|||
};
|
||||
|
||||
bool
|
||||
foz_prepare(struct foz_db *foz_db, char *filename);
|
||||
foz_prepare(struct foz_db *foz_db, char *cache_path);
|
||||
|
||||
void
|
||||
foz_destroy(struct foz_db *foz_db);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue