Loading fs/src/fuse_ops.h +2 −0 Original line number Diff line number Diff line Loading @@ -24,6 +24,8 @@ int adafs_readdir(const char*, void*, fuse_fill_dir_t, off_t, struct fuse_file_i int adafs_releasedir(const char*, struct fuse_file_info*); int adafs_mkdir(const char *, mode_t); // int adafs_flush(const char*, struct fuse_file_info*); Loading fs/src/fuse_ops/directory.cpp +31 −0 Original line number Diff line number Diff line Loading @@ -94,3 +94,34 @@ int adafs_releasedir(const char* p, struct fuse_file_info* ffi) { // At the time of this writing I don't have any cache running. So all dirty stuff is immediately written to disk. return 0; } /** Create a directory * * Note that the mode argument may not have the type specification * bits set, i.e. S_ISDIR(mode) can be false. To obtain the * correct directory type bits use mode|S_IFDIR * */ int adafs_mkdir(const char *p, mode_t mode) { ADAFS_DATA->logger->debug(" ##### FUSE FUNC ###### adafs_mkdir() enter: name '{}' mode {}", p, mode); // XXX mknod and mkdir is strikingly similar. todo merge them. // XXX Errorhandling and beware of transactions. saving dentry and metadata have to be atomic auto path = bfs::path(p); path.remove_trailing_separator(); // XXX check if dir exists (how can we omit this? Let's just try to create it and see if it fails) // XXX check permissions (omittable) // XXX create directory entry for parent directory (can fail) create_dentry(ADAFS_DATA->hashf(path.parent_path().string()), path.filename().string()); // XXX create metadata of new file // mode is used here to init metadata auto md = make_unique<Metadata>(S_IFDIR | mode); write_all_metadata(*md, ADAFS_DATA->hashf(path.string())); // Init structure to hold dentries of new directory init_dentry(ADAFS_DATA->hashf(path.string())); return 0; } No newline at end of file fs/src/fuse_ops/file.cpp +0 −16 Original line number Diff line number Diff line Loading @@ -38,22 +38,6 @@ int adafs_getattr(const char* p, struct stat* attr, struct fuse_file_info* fi) { return 0; } // XXX Testing stuff below. Tobe removed later when files can be created n stuff // if (strcmp(p, "/file") == 0) { // attr->st_mode = S_IFDIR | 0755; // return 0; // } // if (strcmp(p, "/file/file2") == 0) { // auto p_dir = make_shared<struct stat>(); // lstat("/", p_dir.get()); // ADAFS_DATA->logger->debug(p_dir->st_ino); // ADAFS_DATA->logger->flush(); // // attr->st_mode = S_IFREG | 0755; // attr->st_nlink = 1; // attr->st_size = strlen("blubb"); // return 0; // } return -ENOENT; } Loading fs/src/main.cpp +1 −0 Original line number Diff line number Diff line Loading @@ -78,6 +78,7 @@ static void init_adafs_ops(fuse_operations* ops) { ops->opendir = adafs_opendir; ops->readdir = adafs_readdir; ops->releasedir = adafs_releasedir; ops->mkdir = adafs_mkdir; ops->flush = adafs_flush; Loading Loading
fs/src/fuse_ops.h +2 −0 Original line number Diff line number Diff line Loading @@ -24,6 +24,8 @@ int adafs_readdir(const char*, void*, fuse_fill_dir_t, off_t, struct fuse_file_i int adafs_releasedir(const char*, struct fuse_file_info*); int adafs_mkdir(const char *, mode_t); // int adafs_flush(const char*, struct fuse_file_info*); Loading
fs/src/fuse_ops/directory.cpp +31 −0 Original line number Diff line number Diff line Loading @@ -94,3 +94,34 @@ int adafs_releasedir(const char* p, struct fuse_file_info* ffi) { // At the time of this writing I don't have any cache running. So all dirty stuff is immediately written to disk. return 0; } /** Create a directory * * Note that the mode argument may not have the type specification * bits set, i.e. S_ISDIR(mode) can be false. To obtain the * correct directory type bits use mode|S_IFDIR * */ int adafs_mkdir(const char *p, mode_t mode) { ADAFS_DATA->logger->debug(" ##### FUSE FUNC ###### adafs_mkdir() enter: name '{}' mode {}", p, mode); // XXX mknod and mkdir is strikingly similar. todo merge them. // XXX Errorhandling and beware of transactions. saving dentry and metadata have to be atomic auto path = bfs::path(p); path.remove_trailing_separator(); // XXX check if dir exists (how can we omit this? Let's just try to create it and see if it fails) // XXX check permissions (omittable) // XXX create directory entry for parent directory (can fail) create_dentry(ADAFS_DATA->hashf(path.parent_path().string()), path.filename().string()); // XXX create metadata of new file // mode is used here to init metadata auto md = make_unique<Metadata>(S_IFDIR | mode); write_all_metadata(*md, ADAFS_DATA->hashf(path.string())); // Init structure to hold dentries of new directory init_dentry(ADAFS_DATA->hashf(path.string())); return 0; } No newline at end of file
fs/src/fuse_ops/file.cpp +0 −16 Original line number Diff line number Diff line Loading @@ -38,22 +38,6 @@ int adafs_getattr(const char* p, struct stat* attr, struct fuse_file_info* fi) { return 0; } // XXX Testing stuff below. Tobe removed later when files can be created n stuff // if (strcmp(p, "/file") == 0) { // attr->st_mode = S_IFDIR | 0755; // return 0; // } // if (strcmp(p, "/file/file2") == 0) { // auto p_dir = make_shared<struct stat>(); // lstat("/", p_dir.get()); // ADAFS_DATA->logger->debug(p_dir->st_ino); // ADAFS_DATA->logger->flush(); // // attr->st_mode = S_IFREG | 0755; // attr->st_nlink = 1; // attr->st_size = strlen("blubb"); // return 0; // } return -ENOENT; } Loading
fs/src/main.cpp +1 −0 Original line number Diff line number Diff line Loading @@ -78,6 +78,7 @@ static void init_adafs_ops(fuse_operations* ops) { ops->opendir = adafs_opendir; ops->readdir = adafs_readdir; ops->releasedir = adafs_releasedir; ops->mkdir = adafs_mkdir; ops->flush = adafs_flush; Loading