From 4577d8597952e55965965b9174e790cef898f267 Mon Sep 17 00:00:00 2001 From: FactorialN Date: Thu, 30 Nov 2023 01:26:13 -0800 Subject: [PATCH] somewhat runs but apparently I/O is incorrect --- lib/fischl.cpp | 36 +++++++++++++++++++++++++++++------- 1 file changed, 29 insertions(+), 7 deletions(-) diff --git a/lib/fischl.cpp b/lib/fischl.cpp index 066c7a7..84e4f6f 100644 --- a/lib/fischl.cpp +++ b/lib/fischl.cpp @@ -2,7 +2,7 @@ #include #include -#include +#include #include #include #include @@ -33,7 +33,9 @@ static const struct fuse_opt option_spec[] = { }; void* fischl_init(struct fuse_conn_info *conn, struct fuse_config *cfg) { - + options.fsop->initialize_rootinode(); + perror("FUSE INITIALIZATION RUNNING"); + } int fischl_create(const char *path, mode_t mode, struct fuse_file_info *fi) { @@ -45,13 +47,31 @@ void fischl_destroy(void* private_data) { } -static int fischl_getattr(const char *path, struct stat *mode, struct fuse_file_info *fi) { +static int fischl_getattr(const char *path, struct stat *stbuf, struct fuse_file_info *fi) { - return -1; + (void) fi; + int res = 0; + u_int64_t fh = options.fsop->namei(path); + + memset(stbuf, 0, sizeof(struct stat)); + if (strcmp(path, "/") == 0) { + stbuf->st_mode = S_IFDIR | 0755; + stbuf->st_nlink = 2; + } else if (fh != -1) { + stbuf->st_mode = S_IFREG | 0444; + stbuf->st_nlink = 1; + // TO DO: make this the correct value + stbuf->st_size = 3; + } else + res = -ENOENT; + + return res; } static int fischl_access(const char* path, int mask) { - return -1; + + // return 0 when access is allowed + return 0; } static int fischl_readlink(const char* path, char* buf, size_t size) { @@ -59,6 +79,7 @@ static int fischl_readlink(const char* path, char* buf, size_t size) { } static int fischl_opendir(const char* path, struct fuse_file_info* fi) { + perror(path); return -1; } @@ -200,14 +221,15 @@ static void show_help(const char *progname) "\n"); } + int fischl(int argc, char *argv[]) { int ret; struct fuse_args args = FUSE_ARGS_INIT(argc, argv); srand(time(NULL)); // Seed the random number generator - const char* d = (argc < 2) ? "/dev/vdc" : argv[1]; + //const char* d = (argc < 2) ? "/dev/vdc" : argv[1]; - //setupTestDirectory(&options.mock_root); + //setupTestDirectory(&options.root); options.H = new FakeRawDisk(21504); options.fs = new Fs(options.H); options.fs->format();