Lines Matching refs:file

39 #include <sys/file.h>
59 * format uses a 64bit hash table to lookup file offsets for reading cache
75 check_files_opened_successfully(FILE *file, FILE *db_idx)
77 if (!file) {
84 if (file)
85 fclose(file);
109 * to do without locking the file as we assume the file is append only */
150 /* read cache item offset from index file */
166 * 64bit hash table for looking up file offsets.
211 int err = lock_file_with_timeout(foz_db->file[file_idx], 100000000);
236 /* Appending to a fresh file. Make sure we have the magic. */
238 sizeof(stream_reference_magic_and_version), foz_db->file[file_idx]) !=
247 fflush(foz_db->file[file_idx]);
251 flock(fileno(foz_db->file[file_idx]), LOCK_UN);
259 flock(fileno(foz_db->file[file_idx]), LOCK_UN);
279 foz_db->file[0] = fopen(filename, "a+b");
285 if (!check_files_opened_successfully(foz_db->file[0], foz_db->db_idx))
315 foz_db->file[file_idx] = fopen(filename, "rb");
321 if (!check_files_opened_successfully(foz_db->file[file_idx], db_idx)) {
323 foz_db->file[file_idx] = NULL;
349 if (foz_db->file[i])
350 fclose(foz_db->file[i]);
389 if (fseek(foz_db->file[file_idx], entry->offset, SEEK_SET) < 0)
393 if (fread(&entry->header, 1, header_size, foz_db->file[file_idx]) !=
407 if (fread(data, 1, data_sz, foz_db->file[file_idx]) != data_sz)
426 /* reading db entry failed. reset the file offset */
445 * conditions between the write threads sharing the same file descriptor. */
449 * for file contention than mtx contention of significant length. */
450 int err = lock_file_with_timeout(foz_db->file[0], 1000000000);
462 flock(fileno(foz_db->file[0]), LOCK_UN);
474 fseek(foz_db->file[0], 0, SEEK_END);
479 if (fwrite(hash_str, 1, FOSSILIZE_BLOB_HASH_LENGTH, foz_db->file[0]) !=
483 off_t offset = ftell(foz_db->file[0]);
486 if (fwrite(&header, 1, sizeof(header), foz_db->file[0]) != sizeof(header))
490 if (fwrite(blob, 1, blob_size, foz_db->file[0]) != blob_size)
493 /* Flush everything to file to reduce chance of cache corruption */
494 fflush(foz_db->file[0]);
514 /* Flush everything to file to reduce chance of cache corruption */
525 flock(fileno(foz_db->file[0]), LOCK_UN);
533 flock(fileno(foz_db->file[0]), LOCK_UN);
542 fprintf(stderr, "Warning: Mesa single file cache selected but Mesa wasn't "
543 "built with single cache file support. Shader cache will be disabled"