Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions system/lib/wasmfs/syscalls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -759,20 +759,17 @@ int __syscall_getcwd(intptr_t buf, size_t size) {
return -ENOENT;
}

auto parentDir = parent->dynCast<Directory>();

auto name = parentDir->locked().getName(curr);
auto name = parent->locked().getName(curr);
result = '/' + name + result;
curr = parentDir;
curr = parent;
}

// Check if the cwd is the root directory.
if (result.empty()) {
result = "/";
}

auto res = result.c_str();
int len = strlen(res) + 1;
int len = result.length() + 1;

// Check if the size argument is less than the length of the absolute
// pathname of the working directory, including null terminator.
Expand All @@ -781,7 +778,7 @@ int __syscall_getcwd(intptr_t buf, size_t size) {
}

// Return value is a null-terminated c string.
strcpy((char*)buf, res);
strcpy((char*)buf, result.c_str());

return len;
}
Expand Down