Verified Commit 7bde9073 authored by Tommaso Tocci's avatar Tommaso Tocci
Browse files

Bugfix: links to pipe raise exception

In the kernel VFS some file descriptors under /proc/<PID>/fd/ could be
links to a pipe, this is a special case in which the `readlink` function
would not work. So when we detect this case we forward to kernel
parent a9b4c16b
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -144,7 +144,8 @@ unsigned int path_match_components(const std::string& path, unsigned int &path_c
                char link_resolved[PATH_MAX_LEN];
                if (LIBC_FUNC(realpath, resolved.c_str(), link_resolved) == nullptr) {
                    CTX->log()->error("{}() Failed to get realpath for link '{}'. Error: {}", __func__, resolved, strerror(errno));
                    throw std::runtime_error("Failed to get realpath for link '" + resolved + "'. Error: " + strerror(errno));
                    resolved.append(path, end, std::string::npos);
                    return false;
                }
                // substituute resolved with new link path
                resolved = link_resolved;