#include #define FUSE_USE_VERSION 31 #include "sourcefs.h" #include const char *mountpoint; /* * #In this function we need to: * * * Open the folder we are mounting over (and remember it). * * Initialize the process table. */ static void *icfs_init(struct fuse_conn_info *conn, struct fuse_config *cfg) { (void)conn; /* Explicit way to tell we ignore these arguments. */ (void)cfg; /* This also silences the compiler warnings. */ source_init(mountpoint); return NULL; } static int icfs_getattr(const char *path, struct stat *stbuf, struct fuse_file_info *fi) { int statret = source_stat(path, stbuf); //(void)fi; /* int res = 0; memset(stbuf, 0, sizeof(struct stat)); if (strcmp(path, "/") == 0) { stbuf->st_mode = S_IFDIR | 0755; stbuf->st_nlink = 2; } else if (strcmp(path + 1, options.filename) == 0) { stbuf->st_mode = S_IFREG | 0444; stbuf->st_nlink = 1; stbuf->st_size = strlen(options.contents); } else res = -ENOENT; */ // return res; return statret; } static const struct fuse_operations icfs_oper = { .init = icfs_init, .getattr = icfs_getattr, }; int main(int argc, char *argv[]) { int ret; // FUSE won't tell us the mountpoint on it's own, so we need to extract it // ourselves. mountpoint = realpath(argv[argc - 2], NULL); ret = fuse_main(argc, argv, &icfs_oper, NULL); return ret; }