Permalink
Browse files

o Also, debug stat() calls with -R option.

  • Loading branch information...
1 parent 4e69b5b commit 4b5497040cf035bd819425f888cbbf40ee9e8d4d @hzeller committed Oct 6, 2012
Showing with 23 additions and 6 deletions.
  1. +23 −6 folve-main.cc
View
@@ -70,8 +70,19 @@ static int folve_getattr(const char *path, struct stat *stbuf) {
if (result != 0) {
char path_buf[PATH_MAX];
result = lstat(assemble_orig_path(path_buf, path), stbuf);
+ if (folve_rt.readdir_dump_file) {
+ fprintf(folve_rt.readdir_dump_file,
+ "STAT %s mode=%03o %s %s %s", path,
+ stbuf->st_mode & 0777, S_ISDIR(stbuf->st_mode) ? "DIR" : "",
+ (result == -1) ? strerror(errno) : "",
+ ctime(&stbuf->st_mtime)); // ctime ends with \n, so put that last
+ }
if (result == -1)
return -errno;
+ } else {
+ if (folve_rt.readdir_dump_file) {
+ fprintf(folve_rt.readdir_dump_file, "FOLVE-Stat %s\n", path);
+ }
}
// Whatever write mode was there before: now things are readonly.
stbuf->st_mode &= ~(S_IWUSR | S_IWGRP | S_IWOTH);
@@ -93,26 +104,32 @@ static int folve_readdir(const char *path, void *buf, fuse_fill_dir_t filler,
const size_t entry_size = sizeof(struct dirent) + PATH_MAX;
struct dirent *entry_buf = (struct dirent *) malloc(entry_size);
- if (folve_rt.readdir_dump_file)
+ if (folve_rt.readdir_dump_file) {
fprintf(folve_rt.readdir_dump_file, "LIST %s\n", path);
+ }
while (readdir_r(dp, entry_buf, &de) == 0 && de != NULL) {
struct stat st;
memset(&st, 0, sizeof(st));
st.st_ino = de->d_ino;
st.st_mode = de->d_type << 12;
const char *entry_name = de->d_name;
- if (folve_rt.readdir_dump_file)
+ if (folve_rt.readdir_dump_file) {
fprintf(folve_rt.readdir_dump_file, "ITEM %s%s%s\n",
path, strlen(path) > 1 ? "/" : "", de->d_name);
+ }
if (filler(buf, entry_name, &st, 0)) {
- if (folve_rt.readdir_dump_file)
+ if (folve_rt.readdir_dump_file) {
fprintf(folve_rt.readdir_dump_file, "DONE (%s)\n", de->d_name);
+ }
break;
}
}
free(entry_buf);
-
+ if (folve_rt.readdir_dump_file) {
+ fprintf(folve_rt.readdir_dump_file, "DONE %s\n", path);
+ fflush(folve_rt.readdir_dump_file);
+ }
closedir(dp);
return 0;
}
@@ -213,8 +230,8 @@ static int usage(const char *prg) {
"\t and some more detailed configuration info in UI\n"
"\t-f : Operate in foreground; useful for debugging.\n"
"\t-o <mnt-opt> : other generic mount parameters passed to FUSE.\n"
- "\t-d : High volume FUSE debug log. Implies -f.\n",
- "\t-R <file> : Debug readdir() calls. Debug output to file.\n",
+ "\t-d : High volume FUSE debug log. Implies -f.\n"
+ "\t-R <file> : Debug readdir() & stat() calls. Output to file.\n",
folve_rt.refresh_time);
return 1;
}

0 comments on commit 4b54970

Please sign in to comment.