mirror of
https://github.com/EnderIce2/Fennix.git
synced 2025-07-10 23:09:15 +00:00
feat(kernel): implement handling symbolic links in paths
Signed-off-by: EnderIce2 <enderice2@protonmail.com>
This commit is contained in:
@ -161,6 +161,7 @@ namespace vfs
|
||||
}
|
||||
|
||||
Inode *Node = NULL;
|
||||
bool readSymlinks = true; /* FIXME: implement */
|
||||
do
|
||||
{
|
||||
auto it = DeviceMap.find(__Parent->Node->Device);
|
||||
@ -170,6 +171,22 @@ namespace vfs
|
||||
if (it->second.fsi->Ops.Lookup == NULL)
|
||||
ReturnLogError(nullptr, "Lookup not supported for %d", it->first);
|
||||
|
||||
if (readSymlinks && __Parent->IsSymbolicLink())
|
||||
{
|
||||
if (it->second.fsi->Ops.ReadLink == NULL)
|
||||
ReturnLogError(nullptr, "Readlink not supported for %d", it->first);
|
||||
|
||||
char buffer[256];
|
||||
int ret = it->second.fsi->Ops.ReadLink(__Parent->Node, buffer, sizeof(buffer));
|
||||
if (ret < 0)
|
||||
ReturnLogError(nullptr, "Readlink for \"%s\"(%d) failed with %d", __Parent->Path.c_str(), it->first, ret);
|
||||
|
||||
FileNode *target = this->GetByPath(buffer, __Parent->Parent ? __Parent->Parent : __Parent);
|
||||
if (target == nullptr)
|
||||
ReturnLogError(nullptr, "Failed to find target for \"%s\"", __Parent->Path.c_str());
|
||||
__Parent = target;
|
||||
}
|
||||
|
||||
std::string segmentName(segment.begin, segment.size);
|
||||
int ret = it->second.fsi->Ops.Lookup(__Parent->Node, segmentName.c_str(), &Node);
|
||||
if (ret < 0)
|
||||
|
Reference in New Issue
Block a user