From f816ea919c382a3f61385ca440b417487fb3b6a4 Mon Sep 17 00:00:00 2001 From: FactorialN <8838579+FactorialN@users.noreply.github.com> Date: Sat, 2 Dec 2023 18:47:22 -0800 Subject: [PATCH] fixed inode number callback --- include/files.h | 1 + lib/files.cpp | 11 +++++++++++ lib/fischl.cpp | 5 +++-- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/include/files.h b/include/files.h index 0c30d23..85323bd 100644 --- a/include/files.h +++ b/include/files.h @@ -41,4 +41,5 @@ class FilesOperation { int fischl_write(const char *, const char *, size_t, off_t, struct fuse_file_info *); int fischl_read(const char *, char *, size_t, off_t, struct fuse_file_info *); int fischl_utimens(const char *path, const struct timespec tv[2], struct fuse_file_info *fi); + int fischl_statfs(const char* path, struct statvfs* stbuf); }; \ No newline at end of file diff --git a/lib/files.cpp b/lib/files.cpp index 1cc164c..f44cca6 100644 --- a/lib/files.cpp +++ b/lib/files.cpp @@ -495,6 +495,7 @@ int FilesOperation::fischl_chown(const char *path, uid_t uid, gid_t gid, struct int FilesOperation::fischl_unlink(const char* path) { + char *pathdup = strdup(path); char *lastSlash = strrchr(pathdup, '/'); *lastSlash = '\0'; @@ -964,4 +965,14 @@ int FilesOperation::fischl_utimens(const char *path, const struct timespec tv[2] inode.metadata.modification_time = (u_int64_t)tv[1].tv_sec * 1000000000ULL + tv[1].tv_nsec; fs->inode_manager->save_inode(&inode); return 0; +} + +int FilesOperation::fischl_statfs(const char* path, struct statvfs* stbuf) { + stbuf->f_bsize = 4096; + stbuf->f_blocks = 0; + stbuf->f_bfree = 0; + stbuf->f_files = 0; + stbuf->f_ffree = 0; + stbuf->f_namemax = 256; + return 0; } \ No newline at end of file diff --git a/lib/fischl.cpp b/lib/fischl.cpp index a760d36..b85d633 100644 --- a/lib/fischl.cpp +++ b/lib/fischl.cpp @@ -33,6 +33,7 @@ static const struct fuse_opt option_spec[] = { }; void* fischl_init(struct fuse_conn_info *conn, struct fuse_config *cfg) { + cfg->use_ino = 1; options.fsop->initialize_rootinode(); } @@ -126,7 +127,7 @@ static int fischl_write(const char *path, const char *buf, size_t size, off_t of } static int fischl_statfs(const char* path, struct statvfs* stbuf) { - return -1; + return options.fsop->fischl_statfs(path, stbuf); } static int fischl_release(const char* path, struct fuse_file_info *fi) { @@ -156,7 +157,7 @@ static const struct fuse_operations fischl_oper = { .open = fischl_open, .read = fischl_read, .write = fischl_write, - //.statfs = fischl_statfs, + .statfs = fischl_statfs, .release = fischl_release, /* #ifdef HAVE_SETXATTR