Skip to content

Commit

Permalink
added more debug statements
Browse files Browse the repository at this point in the history
  • Loading branch information
fangfufu committed May 5, 2024
1 parent 9a7eabd commit 1a20318
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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
*/
Expand All @@ -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));
}
Expand Down
5 changes: 5 additions & 0 deletions src/fuse_local.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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;
}
}
Expand Down

0 comments on commit 1a20318

Please sign in to comment.