Skip to content

Commit

Permalink
debug symlink
Browse files Browse the repository at this point in the history
  • Loading branch information
iDmple committed Dec 6, 2023
1 parent db44a60 commit 3e5de20
Showing 1 changed file with 20 additions and 14 deletions.
34 changes: 20 additions & 14 deletions source/rpc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,30 +101,30 @@ class GhostFSImpl final : public GhostFS::Server {
std::cout << "LOOKUP server2" << std::endl;

uint64_t parent = req.getParent();
std::cout << "LOOKUP parent:" << parent << std::endl;
std::cout << "LOOKUP parent: " << parent << std::endl;
std::string name = req.getName();
std::cout << "LOOKUP name server" << name << std::endl;
std::cout << "LOOKUP name server: " << name << std::endl;

std::map<std::string, std::string>* mounts = get_user_mounts(user);
std::cout << "LOOKUP mounts server" << mounts << std::endl;
std::cout << "LOOKUP mounts server: " << mounts << std::endl;
bool is_mount = parent == 1 && mounts->contains(name);
std::cout << "LOOKUP is_mount server" << is_mount << std::endl;
std::cout << "LOOKUP is_mount server: " << is_mount << std::endl;
std::filesystem::path file_path;
std::cout << "LOOKUP file_path1 server" << file_path << std::endl;
std::cout << "LOOKUP file_path1 server: " << file_path << std::endl;

if (is_mount) {
file_path = std::filesystem::path(root) / (*mounts)[name];
std::cout << "LOOKUP file_path2 server" << file_path << std::endl;
std::cout << "LOOKUP file_path2 server: " << file_path << std::endl;

} else {
std::string user_root = normalize_path(root, user, suffix);
std::cout << "LOOKUP user_root server" << user_root << std::endl;
std::cout << "LOOKUP user_root server: " << user_root << std::endl;
std::string parent_path_name = parent == 1 ? user_root : ino_to_path[parent];
std::cout << "LOOKUP parent_path_name server" << parent_path_name << std::endl;
std::cout << "LOOKUP parent_path_name server: " << parent_path_name << std::endl;
std::filesystem::path parent_path = std::filesystem::path(parent_path_name);
std::cout << "LOOKUP parent_path server" << parent_path << std::endl;
std::cout << "LOOKUP parent_path server: " << parent_path << std::endl;
file_path = parent_path / std::filesystem::path(name);
std::cout << "LOOKUP file_path3 server" << file_path << std::endl;
std::cout << "LOOKUP file_path3 server: " << file_path << std::endl;
}

// bool access_ok = check_access(root, user, suffix, file_path);
Expand All @@ -135,26 +135,32 @@ class GhostFSImpl final : public GhostFS::Server {
// return kj::READY_NOW;
// }

std::cout << "LOOKUP here server" << std::endl;

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

std::cout << "LOOKUP here2 server" << std::endl;

uint64_t ino;

if (not path_to_ino.contains(file_path)) {
std::cout << "LOOKUP if server" << std::endl;
std::cout << "LOOKUP if server: " << std::endl;
ino = ++current_ino;
ino_to_path[ino] = file_path;
path_to_ino[file_path] = ino;
} else {
std::cout << "LOOKUP else server" << std::endl;
std::cout << "LOOKUP else server: " << std::endl;
ino = path_to_ino[file_path];
}

std::cout << "LOOKUP here3 server" << std::endl;

response.setIno(ino);

// e.attr_timeout = 1.0;
Expand All @@ -166,7 +172,7 @@ class GhostFSImpl final : public GhostFS::Server {

int res = hello_stat(ino, &attr);
int err = errno;
std::cout << "LOOKUP err2 server" << err << std::endl;
std::cout << "LOOKUP err2 server: " << err << std::endl;

LookupResponse::Attr::Builder attributes = response.initAttr();

Expand Down

0 comments on commit 3e5de20

Please sign in to comment.