diff --git a/interfaces/kits/js/src/mod_fs/properties/close.cpp b/interfaces/kits/js/src/mod_fs/properties/close.cpp index 76b639afe10b73f5bd3e418fa2347ac03beda858..941e958a336cbe8f867c998ca6dd9a4290b93e38 100644 --- a/interfaces/kits/js/src/mod_fs/properties/close.cpp +++ b/interfaces/kits/js/src/mod_fs/properties/close.cpp @@ -44,6 +44,19 @@ static FileEntity *GetFileEntity(napi_env env, napi_value objFile) static NError CloseFd(int fd) { + std::unique_ptr readlink_req = { + new uv_fs_t, CommonFunc::fs_req_cleanup }; + if (!readlink_req) { + HILOGE("Failed to request heap memory."); + return NError(ENOMEM); + } + string path = "/proc/self/fd/" + to_string(fd); + int readlinkRet = uv_fs_readlink(nullptr, readlink_req.get(), path.c_str(), nullptr); + if (readlinkRet < 0) { + HILOGE("Failed to readlink fd, ret: %{public}d", readlinkRet); + return NError(readlinkRet); + } + HILOGI("In CloseFd, filePath=%{public}s", static_cast(readlink_req->ptr)); std::unique_ptr close_req = { new uv_fs_t, CommonFunc::fs_req_cleanup }; if (!close_req) {