Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed symlink bug #22

Merged
merged 21 commits into from
Feb 14, 2024
14 changes: 10 additions & 4 deletions source/auth.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,16 +94,22 @@ bool is_subpath(const std::filesystem::path& root, const std::filesystem::path&
return mismatch_pair.second == root.end();
}

bool check_access(std::string root, std::string user_id, std::string suffix, std::string path) {
if (not std::filesystem::exists(path)) {
return true;
}
bool check_exists(std::filesystem::path path) {
std::error_code ec;
bool ok = std::filesystem::exists(path, ec);
return ok;
}

bool check_access(std::string root, std::string user_id, std::string suffix, std::string path) {
std::filesystem::path user_root = normalize_path(root, user_id, suffix);

auto const root_can = user_root.lexically_normal();
auto const path_can = std::filesystem::path(path).lexically_normal();

if (not check_exists(path_can)) {
return true;
}

if (root_can == path_can) {
return true;
}
Expand Down
13 changes: 2 additions & 11 deletions source/fs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,6 @@ static void hello_ll_getattr(fuse_req_t req, fuse_ino_t ino, struct fuse_file_in
int res = response.getRes();

if (res == -1) {
// std::cout << "GETATTR::ENOENT" << std::endl;
fuse_reply_err(req, response.getErrno());
return;
}
Expand Down Expand Up @@ -295,8 +294,6 @@ static void hello_ll_lookup(fuse_req_t req, fuse_ino_t parent, const char *name)
lookup.setParent(parent);
lookup.setName(name);

// std::cout << "LOOKUP name: " << name << std::endl;

auto promise = request.send();
auto result = promise.wait(waitScope);
auto response = result.getRes();
Expand All @@ -308,7 +305,6 @@ static void hello_ll_lookup(fuse_req_t req, fuse_ino_t parent, const char *name)
int res = response.getRes();

if (res == -1) {
// std::cout << "LOOKUP::ENOENT" << std::endl;
fuse_reply_err(req, response.getErrno());
return;
}
Expand Down Expand Up @@ -338,7 +334,7 @@ static void hello_ll_lookup(fuse_req_t req, fuse_ino_t parent, const char *name)

fuse_reply_entry(req, &e);

// std::cout << "hello_ll_lookup executed correctly: " << payload << std::endl;
// std::cout << "hello_ll_lookup executed correctly" << std::endl;
}

/**
Expand Down Expand Up @@ -882,7 +878,6 @@ static void hello_ll_mknod(fuse_req_t req, fuse_ino_t parent, const char *name,
int res = response.getRes();

if (res == -1) {
// std::cout << "MKNOD::ENOENT" << std::endl;
fuse_reply_err(req, response.getErrno());
return;
}
Expand Down Expand Up @@ -993,7 +988,6 @@ static void hello_ll_create(fuse_req_t req, fuse_ino_t parent, const char *name,
int res = response.getRes();

if (res == -1) {
// std::cout << "CREATE::ENOENT" << std::endl;
fuse_reply_err(req, response.getErrno());
return;
}
Expand Down Expand Up @@ -1057,7 +1051,6 @@ static void hello_ll_mkdir(fuse_req_t req, fuse_ino_t parent, const char *name,
int res = response.getRes();

if (res == -1) {
// std::cout << "MKDIR::ENOENT" << std::endl;
fuse_reply_err(req, response.getErrno());
return;
}
Expand Down Expand Up @@ -1294,7 +1287,6 @@ static void hello_ll_setattr(fuse_req_t req, fuse_ino_t ino, struct stat *attr,
int res = response.getRes();

if (res == -1) {
// std::cout << "SETATTR::ENOENT" << std::endl;
fuse_reply_err(req, response.getErrno());
return;
}
Expand Down Expand Up @@ -1327,7 +1319,6 @@ static void hello_ll_setxattr(fuse_req_t req, fuse_ino_t ino, const char *name,
int res = response.getRes();

if (res == -1) {
// std::cout << "SETXATTR::ENOENT" << std::endl;
fuse_reply_err(req, response.getErrno());
return;
}
Expand Down Expand Up @@ -1360,7 +1351,7 @@ static void hello_ll_readlink(fuse_req_t req, fuse_ino_t ino) {
fuse_reply_readlink(req, link.c_str());
}

// std::cout << "readlink executed correctly: " << payload << std::endl;
// std::cout << "readlink executed correctly " << std::endl;
}

// clang-format off
Expand Down
7 changes: 0 additions & 7 deletions source/rpc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,6 @@ class GhostFSImpl final : public GhostFS::Server {
return kj::READY_NOW;
}

if (not std::filesystem::exists(file_path)) {
int err = errno;
response.setErrno(err);
response.setRes(-1);
return kj::READY_NOW;
}

uint64_t ino;

if (not path_to_ino.contains(file_path)) {
Expand Down
Loading