Loading fs/src/adafs_ops/access.cpp +8 −6 Original line number Diff line number Diff line Loading @@ -5,12 +5,14 @@ #include "access.h" /** * * Checks access for mask (can be R_OK, W_OK, or R_OK | W_OK AFAIK and not verified) against metadata's mode. * First the mask is checked agains the 3 bits for the user, then for the 3 bits of the group, and lastly other. * If all three checks have failed, return -EACCESS (no access) * @param md * @param mode * @param mask * @return */ int chk_access(const Metadata& md, const int mode) { int chk_access(const Metadata& md, const int mask) { ADAFS_DATA->logger->debug("chk_access() enter: metadata_uid {} fusecontext_uid {}", md.uid(), fuse_get_context()->uid); // root user is a god Loading @@ -20,7 +22,7 @@ int chk_access(const Metadata& md, const int mode) { //check user leftmost 3 bits for rwx in md->mode if (md.uid() == fuse_get_context()->uid) { // 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) if ((mask & md.mode() >> 6) == (unsigned int) mask) return 0; else return -EACCES; Loading @@ -28,7 +30,7 @@ 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) { if ((mode & md.mode() >> 3) == (unsigned int) mode) if ((mask & md.mode() >> 3) == (unsigned int) mask) return 0; else return -EACCES; Loading @@ -36,7 +38,7 @@ int chk_access(const Metadata& md, const int mode) { //check other rightmost 3 bits for rwx in md->mode. // Because they are the rightmost bits they don't need to be shifted if ((mode & md.mode()) == (unsigned int) mode) { if ((mask & md.mode()) == (unsigned int) mask) { return 0; } Loading fs/src/adafs_ops/access.h +1 −1 Original line number Diff line number Diff line Loading @@ -8,7 +8,7 @@ #include "../classes/metadata.h" int chk_access(const Metadata& md, const int mode); int chk_access(const Metadata& md, const int mask); #endif //FS_ACCESS_H fs/src/fuse_ops/access.cpp +10 −3 Original line number Diff line number Diff line Loading @@ -4,6 +4,8 @@ #include "../main.h" #include "../fuse_ops.h" #include "../adafs_ops/metadata_ops.h" #include "../adafs_ops/access.h" using namespace std; Loading @@ -17,8 +19,13 @@ using namespace std; * This method is not called under Linux kernel versions 2.4.x */ int adafs_access(const char* p, int mask) { ADAFS_DATA->logger->info("##### FUSE FUNC ###### adafs_access() enter: name '{}' mask {}", p, mask); // XXX To be implemented for rm return 0; ADAFS_DATA->logger->debug("##### FUSE FUNC ###### adafs_access() enter: name '{}' mask {}", p, mask); auto path = bfs::path(p); auto md = make_shared<Metadata>(); // XXX error handling get_metadata(*md, path); return chk_access(*md, mask); } Loading
fs/src/adafs_ops/access.cpp +8 −6 Original line number Diff line number Diff line Loading @@ -5,12 +5,14 @@ #include "access.h" /** * * Checks access for mask (can be R_OK, W_OK, or R_OK | W_OK AFAIK and not verified) against metadata's mode. * First the mask is checked agains the 3 bits for the user, then for the 3 bits of the group, and lastly other. * If all three checks have failed, return -EACCESS (no access) * @param md * @param mode * @param mask * @return */ int chk_access(const Metadata& md, const int mode) { int chk_access(const Metadata& md, const int mask) { ADAFS_DATA->logger->debug("chk_access() enter: metadata_uid {} fusecontext_uid {}", md.uid(), fuse_get_context()->uid); // root user is a god Loading @@ -20,7 +22,7 @@ int chk_access(const Metadata& md, const int mode) { //check user leftmost 3 bits for rwx in md->mode if (md.uid() == fuse_get_context()->uid) { // 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) if ((mask & md.mode() >> 6) == (unsigned int) mask) return 0; else return -EACCES; Loading @@ -28,7 +30,7 @@ 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) { if ((mode & md.mode() >> 3) == (unsigned int) mode) if ((mask & md.mode() >> 3) == (unsigned int) mask) return 0; else return -EACCES; Loading @@ -36,7 +38,7 @@ int chk_access(const Metadata& md, const int mode) { //check other rightmost 3 bits for rwx in md->mode. // Because they are the rightmost bits they don't need to be shifted if ((mode & md.mode()) == (unsigned int) mode) { if ((mask & md.mode()) == (unsigned int) mask) { return 0; } Loading
fs/src/adafs_ops/access.h +1 −1 Original line number Diff line number Diff line Loading @@ -8,7 +8,7 @@ #include "../classes/metadata.h" int chk_access(const Metadata& md, const int mode); int chk_access(const Metadata& md, const int mask); #endif //FS_ACCESS_H
fs/src/fuse_ops/access.cpp +10 −3 Original line number Diff line number Diff line Loading @@ -4,6 +4,8 @@ #include "../main.h" #include "../fuse_ops.h" #include "../adafs_ops/metadata_ops.h" #include "../adafs_ops/access.h" using namespace std; Loading @@ -17,8 +19,13 @@ using namespace std; * This method is not called under Linux kernel versions 2.4.x */ int adafs_access(const char* p, int mask) { ADAFS_DATA->logger->info("##### FUSE FUNC ###### adafs_access() enter: name '{}' mask {}", p, mask); // XXX To be implemented for rm return 0; ADAFS_DATA->logger->debug("##### FUSE FUNC ###### adafs_access() enter: name '{}' mask {}", p, mask); auto path = bfs::path(p); auto md = make_shared<Metadata>(); // XXX error handling get_metadata(*md, path); return chk_access(*md, mask); }