Loading fs/src/adafs_ops/dentry_ops.cpp +1 −0 Original line number Diff line number Diff line Loading @@ -65,6 +65,7 @@ int read_dentries(vector<string>& dir, const unsigned long hash) { * @return */ int create_dentry(const unsigned long parent_dir_hash, const string& fname) { ADAFS_DATA->logger->debug("create_dentry() enter with fname: {}", fname); // XXX Errorhandling auto f_path = bfs::path(ADAFS_DATA->dentry_path); f_path /= to_string(parent_dir_hash); Loading fs/src/fuse_ops/directory.cpp +5 −3 Original line number Diff line number Diff line Loading @@ -18,7 +18,7 @@ using namespace std; * passed to readdir, closedir and fsyncdir. */ int adafs_opendir(const char* p, struct fuse_file_info* fi) { ADAFS_DATA->logger->debug("FUSE: adafs_opendir() enter"s); ADAFS_DATA->logger->debug(" ##### FUSE FUNC ###### adafs_opendir() enter: name '{}'", p); // XXX error handling auto path = bfs::path(p); auto md = make_shared<Metadata>(); Loading Loading @@ -59,7 +59,7 @@ int adafs_opendir(const char* p, struct fuse_file_info* fi) { */ int adafs_readdir(const char* p, void* buf, fuse_fill_dir_t filler, off_t offset, struct fuse_file_info* fi, enum fuse_readdir_flags flags) { ADAFS_DATA->logger->debug("FUSE: adafs_readdir() enter"s); ADAFS_DATA->logger->debug(" ##### FUSE FUNC ###### adafs_readdir() enter: name {} readdir_flags '{}'", p, flags); // XXX ls also reports the number of allocated blocks IN the directory. Non recursive. Currently not considered Loading @@ -81,6 +81,7 @@ int adafs_readdir(const char* p, void* buf, fuse_fill_dir_t filler, off_t offset filler(buf, "..", NULL, 0, FUSE_FILL_DIR_PLUS); for (auto& dentry : *dentries) { // XXX I have no idea what the last parameter really does... ADAFS_DATA->logger->debug("readdir entries: dentry: {}", dentry); filler(buf, dentry.c_str(), NULL, 0, FUSE_FILL_DIR_PLUS); } Loading @@ -89,7 +90,8 @@ int adafs_readdir(const char* p, void* buf, fuse_fill_dir_t filler, off_t offset /** Release directory */ int adafs_releasedir(const char* p, struct fuse_file_info* ffi) { int adafs_releasedir(const char* p, struct fuse_file_info* fi) { ADAFS_DATA->logger->debug(" ##### FUSE FUNC ###### adafs_releasedir() enter: name '{}'", p); // XXX Dunno what to do with that function yet. Maybe flush dirty dentries that are in cache? // At the time of this writing I don't have any cache running. So all dirty stuff is immediately written to disk. return 0; Loading fs/src/fuse_ops/file.cpp +5 −4 Original line number Diff line number Diff line Loading @@ -19,7 +19,7 @@ using namespace std; * may also be NULL if the file is open. */ int adafs_getattr(const char* p, struct stat* attr, struct fuse_file_info* fi) { ADAFS_DATA->logger->info(" ##### FUSE FUNC ###### adafs_getattr() enter: name '{}' initial_inode {}", p, attr->st_ino); auto path = bfs::path(p); auto md = make_shared<Metadata>(); Loading Loading @@ -48,7 +48,7 @@ int adafs_getattr(const char* p, struct stat* attr, struct fuse_file_info* fi) { * regular files that will be called instead. */ int adafs_mknod(const char* p, mode_t mode, dev_t dev) { ADAFS_DATA->logger->debug("FUSE: adafs_readdir() enter"s); ADAFS_DATA->logger->debug(" ##### FUSE FUNC ###### adafs_mknod() enter: name '{}' mode {} dev {}", p, mode, dev); // XXX Errorhandling and beware of transactions. saving dentry and metadata have to be atomic auto path = bfs::path(p); Loading @@ -61,7 +61,7 @@ int adafs_mknod(const char* p, mode_t mode, dev_t dev) { // XXX create metadata of new file // mode is used here to init metadata auto md = make_unique<Metadata>(mode); auto md = make_unique<Metadata>(S_IFREG | mode); write_all_metadata(*md, ADAFS_DATA->hashf(path.string())); return 0; Loading @@ -83,7 +83,7 @@ int adafs_mknod(const char* p, mode_t mode, dev_t dev) { * passed to all file operations. */ int adafs_open(const char* p, struct fuse_file_info* fi) { ADAFS_DATA->logger->debug("FUSE: adafs_open() enter"s); ADAFS_DATA->logger->debug(" ##### FUSE FUNC ###### adafs_open() enter: name '{}'", p); // XXX error handling auto path = bfs::path(p); auto md = make_shared<Metadata>(); Loading Loading @@ -117,6 +117,7 @@ int adafs_open(const char* p, struct fuse_file_info* fi) { * See the utimensat(2) man page for details. */ int adafs_utimens(const char* p, const struct timespec tv[2], struct fuse_file_info* fi) { ADAFS_DATA->logger->debug(" ##### FUSE FUNC ###### adafs_utimens() enter: name '{}'", p); // XXX ignored for now. Later: Make it configurable return 0; } fs/src/fuse_ops/permission.cpp +1 −5 Original line number Diff line number Diff line Loading @@ -7,15 +7,13 @@ using namespace std; int chk_access(const Metadata& md, const int mode) { ADAFS_DATA->logger->debug("chk_access() enter: md.uid: {}, fusecontextuid: {}", md.uid(), fuse_get_context()->uid); ADAFS_DATA->logger->debug("chk_access() enter: metadata_uid {} fusecontext_uid {}", md.uid(), fuse_get_context()->uid); // root user is a god if (fuse_get_context()->uid == 0) return 0; //check user leftmost 3 bits for rwx in md->mode if (md.uid() == fuse_get_context()->uid) { ADAFS_DATA->logger->debug("Metadata UID: {}, fuse context uid: {}, mode: {}", md.uid(), fuse_get_context()->uid, mode); // Because mode comes only with the first 3 bits used, the user bits have to be shifted to the right to compare if ((mode & md.mode() >> 6) == (unsigned int) mode) return 0; Loading @@ -25,8 +23,6 @@ int chk_access(const Metadata& md, const int mode) { //check group middle 3 bits for rwx in md->mode if (md.gid() == fuse_get_context()->gid) { ADAFS_DATA->logger->debug("Metadata GID: {}, fuse context gid: {}, mode: {}", md.uid(), fuse_get_context()->gid, mode); if ((mode & md.mode() >> 3) == (unsigned int) mode) return 0; else Loading fs/src/fuse_ops/sync.cpp +1 −0 Original line number Diff line number Diff line Loading @@ -28,5 +28,6 @@ */ // currently a NO-OP in ADA-FS int adafs_flush(const char* p, struct fuse_file_info*) { ADAFS_DATA->logger->debug(" ##### FUSE FUNC ###### adafs_flush() enter: name '{}'", p); return 0; } Loading
fs/src/adafs_ops/dentry_ops.cpp +1 −0 Original line number Diff line number Diff line Loading @@ -65,6 +65,7 @@ int read_dentries(vector<string>& dir, const unsigned long hash) { * @return */ int create_dentry(const unsigned long parent_dir_hash, const string& fname) { ADAFS_DATA->logger->debug("create_dentry() enter with fname: {}", fname); // XXX Errorhandling auto f_path = bfs::path(ADAFS_DATA->dentry_path); f_path /= to_string(parent_dir_hash); Loading
fs/src/fuse_ops/directory.cpp +5 −3 Original line number Diff line number Diff line Loading @@ -18,7 +18,7 @@ using namespace std; * passed to readdir, closedir and fsyncdir. */ int adafs_opendir(const char* p, struct fuse_file_info* fi) { ADAFS_DATA->logger->debug("FUSE: adafs_opendir() enter"s); ADAFS_DATA->logger->debug(" ##### FUSE FUNC ###### adafs_opendir() enter: name '{}'", p); // XXX error handling auto path = bfs::path(p); auto md = make_shared<Metadata>(); Loading Loading @@ -59,7 +59,7 @@ int adafs_opendir(const char* p, struct fuse_file_info* fi) { */ int adafs_readdir(const char* p, void* buf, fuse_fill_dir_t filler, off_t offset, struct fuse_file_info* fi, enum fuse_readdir_flags flags) { ADAFS_DATA->logger->debug("FUSE: adafs_readdir() enter"s); ADAFS_DATA->logger->debug(" ##### FUSE FUNC ###### adafs_readdir() enter: name {} readdir_flags '{}'", p, flags); // XXX ls also reports the number of allocated blocks IN the directory. Non recursive. Currently not considered Loading @@ -81,6 +81,7 @@ int adafs_readdir(const char* p, void* buf, fuse_fill_dir_t filler, off_t offset filler(buf, "..", NULL, 0, FUSE_FILL_DIR_PLUS); for (auto& dentry : *dentries) { // XXX I have no idea what the last parameter really does... ADAFS_DATA->logger->debug("readdir entries: dentry: {}", dentry); filler(buf, dentry.c_str(), NULL, 0, FUSE_FILL_DIR_PLUS); } Loading @@ -89,7 +90,8 @@ int adafs_readdir(const char* p, void* buf, fuse_fill_dir_t filler, off_t offset /** Release directory */ int adafs_releasedir(const char* p, struct fuse_file_info* ffi) { int adafs_releasedir(const char* p, struct fuse_file_info* fi) { ADAFS_DATA->logger->debug(" ##### FUSE FUNC ###### adafs_releasedir() enter: name '{}'", p); // XXX Dunno what to do with that function yet. Maybe flush dirty dentries that are in cache? // At the time of this writing I don't have any cache running. So all dirty stuff is immediately written to disk. return 0; Loading
fs/src/fuse_ops/file.cpp +5 −4 Original line number Diff line number Diff line Loading @@ -19,7 +19,7 @@ using namespace std; * may also be NULL if the file is open. */ int adafs_getattr(const char* p, struct stat* attr, struct fuse_file_info* fi) { ADAFS_DATA->logger->info(" ##### FUSE FUNC ###### adafs_getattr() enter: name '{}' initial_inode {}", p, attr->st_ino); auto path = bfs::path(p); auto md = make_shared<Metadata>(); Loading Loading @@ -48,7 +48,7 @@ int adafs_getattr(const char* p, struct stat* attr, struct fuse_file_info* fi) { * regular files that will be called instead. */ int adafs_mknod(const char* p, mode_t mode, dev_t dev) { ADAFS_DATA->logger->debug("FUSE: adafs_readdir() enter"s); ADAFS_DATA->logger->debug(" ##### FUSE FUNC ###### adafs_mknod() enter: name '{}' mode {} dev {}", p, mode, dev); // XXX Errorhandling and beware of transactions. saving dentry and metadata have to be atomic auto path = bfs::path(p); Loading @@ -61,7 +61,7 @@ int adafs_mknod(const char* p, mode_t mode, dev_t dev) { // XXX create metadata of new file // mode is used here to init metadata auto md = make_unique<Metadata>(mode); auto md = make_unique<Metadata>(S_IFREG | mode); write_all_metadata(*md, ADAFS_DATA->hashf(path.string())); return 0; Loading @@ -83,7 +83,7 @@ int adafs_mknod(const char* p, mode_t mode, dev_t dev) { * passed to all file operations. */ int adafs_open(const char* p, struct fuse_file_info* fi) { ADAFS_DATA->logger->debug("FUSE: adafs_open() enter"s); ADAFS_DATA->logger->debug(" ##### FUSE FUNC ###### adafs_open() enter: name '{}'", p); // XXX error handling auto path = bfs::path(p); auto md = make_shared<Metadata>(); Loading Loading @@ -117,6 +117,7 @@ int adafs_open(const char* p, struct fuse_file_info* fi) { * See the utimensat(2) man page for details. */ int adafs_utimens(const char* p, const struct timespec tv[2], struct fuse_file_info* fi) { ADAFS_DATA->logger->debug(" ##### FUSE FUNC ###### adafs_utimens() enter: name '{}'", p); // XXX ignored for now. Later: Make it configurable return 0; }
fs/src/fuse_ops/permission.cpp +1 −5 Original line number Diff line number Diff line Loading @@ -7,15 +7,13 @@ using namespace std; int chk_access(const Metadata& md, const int mode) { ADAFS_DATA->logger->debug("chk_access() enter: md.uid: {}, fusecontextuid: {}", md.uid(), fuse_get_context()->uid); ADAFS_DATA->logger->debug("chk_access() enter: metadata_uid {} fusecontext_uid {}", md.uid(), fuse_get_context()->uid); // root user is a god if (fuse_get_context()->uid == 0) return 0; //check user leftmost 3 bits for rwx in md->mode if (md.uid() == fuse_get_context()->uid) { ADAFS_DATA->logger->debug("Metadata UID: {}, fuse context uid: {}, mode: {}", md.uid(), fuse_get_context()->uid, mode); // Because mode comes only with the first 3 bits used, the user bits have to be shifted to the right to compare if ((mode & md.mode() >> 6) == (unsigned int) mode) return 0; Loading @@ -25,8 +23,6 @@ int chk_access(const Metadata& md, const int mode) { //check group middle 3 bits for rwx in md->mode if (md.gid() == fuse_get_context()->gid) { ADAFS_DATA->logger->debug("Metadata GID: {}, fuse context gid: {}, mode: {}", md.uid(), fuse_get_context()->gid, mode); if ((mode & md.mode() >> 3) == (unsigned int) mode) return 0; else Loading
fs/src/fuse_ops/sync.cpp +1 −0 Original line number Diff line number Diff line Loading @@ -28,5 +28,6 @@ */ // currently a NO-OP in ADA-FS int adafs_flush(const char* p, struct fuse_file_info*) { ADAFS_DATA->logger->debug(" ##### FUSE FUNC ###### adafs_flush() enter: name '{}'", p); return 0; }