Lines Matching refs:fn
403 char* fn; in GetStashFileName() local
420 fn = malloc(len); in GetStashFileName()
422 if (fn == NULL) { in GetStashFileName()
427 res = snprintf(fn, len, STASH_DIRECTORY_BASE "/%s/%s%s", base, id, postfix); in GetStashFileName()
431 free(fn); in GetStashFileName()
435 return fn; in GetStashFileName()
446 char* fn; in EnumerateStash() local
471 fn = malloc(len); in EnumerateStash()
473 if (fn == NULL) { in EnumerateStash()
478 res = snprintf(fn, len, "%s/%s", dirname, item->d_name); in EnumerateStash()
482 free(fn); in EnumerateStash()
486 callback(fn, data); in EnumerateStash()
487 free(fn); in EnumerateStash()
495 static void UpdateFileSize(const char* fn, void* data) { in UpdateFileSize() argument
499 if (!fn || !data) { in UpdateFileSize()
503 if (stat(fn, &st) == -1) { in UpdateFileSize()
504 fprintf(stderr, "stat \"%s\" failed: %s\n", fn, strerror(errno)); in UpdateFileSize()
515 static void DeleteFile(const char* fn, void* data) { in DeleteFile() argument
516 if (fn) { in DeleteFile()
517 fprintf(stderr, "deleting %s\n", fn); in DeleteFile()
519 if (unlink(fn) == -1 && errno != ENOENT) { in DeleteFile()
520 fprintf(stderr, "unlink \"%s\" failed: %s\n", fn, strerror(errno)); in DeleteFile()
525 static void DeletePartial(const char* fn, void* data) { in DeletePartial() argument
526 if (fn && strstr(fn, ".partial") != NULL) { in DeletePartial()
527 DeleteFile(fn, data); in DeletePartial()
558 char *fn = NULL; in LoadStash() local
573 fn = GetStashFileName(base, id, NULL); in LoadStash()
575 if (fn == NULL) { in LoadStash()
579 res = stat(fn, &st); in LoadStash()
583 fprintf(stderr, "stat \"%s\" failed: %s\n", fn, strerror(errno)); in LoadStash()
588 fprintf(stderr, " loading %s\n", fn); in LoadStash()
591 fprintf(stderr, "%s size %zd not multiple of block size %d", fn, st.st_size, BLOCKSIZE); in LoadStash()
595 fd = TEMP_FAILURE_RETRY(open(fn, O_RDONLY)); in LoadStash()
598 fprintf(stderr, "open \"%s\" failed: %s\n", fn, strerror(errno)); in LoadStash()
611 fprintf(stderr, "unexpected contents in %s\n", fn); in LoadStash()
612 DeleteFile(fn, NULL); in LoadStash()
623 if (fn) { in LoadStash()
624 free(fn); in LoadStash()
632 char *fn = NULL; in WriteStash() local
649 fn = GetStashFileName(base, id, ".partial"); in WriteStash()
652 if (fn == NULL || cn == NULL) { in WriteStash()
674 fd = TEMP_FAILURE_RETRY(open(fn, O_WRONLY | O_CREAT | O_TRUNC | O_SYNC, STASH_FILE_MODE)); in WriteStash()
677 fprintf(stderr, "failed to create \"%s\": %s\n", fn, strerror(errno)); in WriteStash()
686 fprintf(stderr, "fsync \"%s\" failed: %s\n", fn, strerror(errno)); in WriteStash()
690 if (rename(fn, cn) == -1) { in WriteStash()
691 fprintf(stderr, "rename(\"%s\", \"%s\") failed: %s\n", fn, cn, strerror(errno)); in WriteStash()
720 if (fn) { in WriteStash()
721 free(fn); in WriteStash()
857 char *fn = NULL; in FreeStash() local
863 fn = GetStashFileName(base, id, NULL); in FreeStash()
865 if (fn == NULL) { in FreeStash()
869 DeleteFile(fn, NULL); in FreeStash()
870 free(fn); in FreeStash()