added more debug statements

This commit is contained in:
Fufu Fang 2024-05-05 02:55:10 +01:00
parent 9a7eabd170
commit 1a20318654
No known key found for this signature in database
GPG Key ID: 8A4CB08B0A7E27CE
2 changed files with 13 additions and 1 deletions

View File

@ -163,12 +163,15 @@ static int Meta_read(Cache *cf)
return EIO;
}
/*
* TODO: This appears to be broken
*/
if (sizeof(long) != fread(&cf->time, sizeof(long), 1, fp) ||
sizeof(off_t) != fread(&cf->content_length, sizeof(off_t), 1, fp) ||
sizeof(int) != fread(&cf->blksz, sizeof(int), 1, fp) ||
sizeof(long) != fread(&cf->segbc, sizeof(long), 1, fp) ||
ferror(fp)) {
lprintf(error, "error reading core metadata!\n");
lprintf(error, "error reading core metadata %s!\n", cf->path);
return EIO;
}
@ -541,7 +544,9 @@ static void Cache_free(Cache *cf)
static int Cache_exist(const char *fn)
{
char *metafn = path_append(META_DIR, fn);
lprintf(debug, "metafn: %s\n", metafn);
char *datafn = path_append(DATA_DIR, fn);
lprintf(debug, "datafn: %s\n", datafn);
/*
* access() returns 0 on success
*/
@ -551,11 +556,13 @@ static int Cache_exist(const char *fn)
if (no_meta ^ no_data) {
lprintf(warning, "Cache file partially missing.\n");
if (no_meta) {
lprintf(debug, "Unlinking datafn: %s\n", datafn);
if (unlink(datafn)) {
lprintf(fatal, "unlink(): %s\n", strerror(errno));
}
}
if (no_data) {
lprintf(debug, "Unlinking metafn: %s\n", metafn);
if (unlink(metafn)) {
lprintf(fatal, "unlink(): %s\n", strerror(errno));
}

View File

@ -100,14 +100,18 @@ static int fs_open(const char *path, struct fuse_file_info *fi)
return -EROFS;
}
if (CACHE_SYSTEM_INIT) {
lprintf(debug, "Cache_open(%s);\n", path);
fi->fh = (uint64_t) Cache_open(path);
if (!fi->fh) {
/*
* The link clearly exists, the cache cannot be opened, attempt
* cache creation
*/
lprintf(debug, "Cache_delete(%s);\n", path);
Cache_delete(path);
lprintf(debug, "Cache_create(%s);\n", path);
Cache_create(path);
lprintf(debug, "Cache_open(%s);\n", path);
fi->fh = (uint64_t) Cache_open(path);
/*
* The cache definitely cannot be opened for some reason.
@ -117,6 +121,7 @@ static int fs_open(const char *path, struct fuse_file_info *fi)
* percentage encoded
*/
if (!fi->fh) {
lprintf(fatal, "Cache file creation failure for %s.\n", path);
return -ENOENT;
}
}