diff --git a/services/ptable_parse/ufs_ptable.cpp b/services/ptable_parse/ufs_ptable.cpp index b4cee23a86f38c2680163081545400987ea4150f..0c6e7e0178ccffa462e1246597ee14a2c470bddf 100644 --- a/services/ptable_parse/ufs_ptable.cpp +++ b/services/ptable_parse/ufs_ptable.cpp @@ -45,13 +45,15 @@ uint32_t UfsPtable::GetPtableExtraOffset(void) } // avoid u disk being recognized as a valid gpt lun device -bool UfsPtable::IsUsbPath(const char* filePath) +bool UfsPtable::IsUsbPath(const uint32_t lunIndex) { + char lunIndexName = 'a' + lunIndex; const char* targetUsbString = "usb"; const char* targetXhciString = "xhci"; char linkBuf[READ_LINK_BUFFER_LENTH] = {0}; - ssize_t retSize = readlink(filePath, linkBuf, READ_LINK_BUFFER_LENTH - 1); - LOG(INFO) << "readlibk " << filePath << " retSzie " << retSize << ", linkBuf is: " << linkBuf; + std::string filePath = std::string(PREFIX_SYS_CLASS_BLOCK) + lunIndexName; + ssize_t retSize = readlink(filePath.c_str(), linkBuf, READ_LINK_BUFFER_LENTH - 1); + LOG(INFO) << "readlink " << filePath << " retSzie " << retSize << ", linkBuf is: " << linkBuf; if (retSize > 0 && (strstr(linkBuf, targetUsbString) != nullptr || strstr(linkBuf, targetXhciString) != nullptr)) { return true; } @@ -101,7 +103,7 @@ void UfsPtable::SetDeviceLunNum() break; } #ifndef UPDATER_UT - if (CheckDeviceLunRemoveable(lunIndex) || IsUsbPath(ufsNode.c_str())) { + if (CheckDeviceLunRemoveable(lunIndex) || IsUsbPath(lunIndex)) { LOG(ERROR) << "device " << ufsNode << " is removable, may be a u disk"; break; } diff --git a/services/ptable_parse/ufs_ptable.h b/services/ptable_parse/ufs_ptable.h index 96ae8fe7fd5021f3b0a383469a6c8ca914de5202..f6ee78090190d434458ed82295978e7feb53147c 100644 --- a/services/ptable_parse/ufs_ptable.h +++ b/services/ptable_parse/ufs_ptable.h @@ -78,7 +78,7 @@ public: uint8_t *GetPtableImageUfsLunPmbrStart(uint8_t *imageBuf, const uint32_t lunIndex); uint8_t *GetPtableImageUfsLunGptHeaderStart(uint8_t *imageBuf, const uint32_t lunIndex); uint8_t *GetPtableImageUfsLunEntryStart(uint8_t *imageBuf, const uint32_t lunIndex); - bool IsUsbPath(const char* filePath); + bool IsUsbPath(const uint32_t lunIndex); }; } // namespace Updater #endif // UPDATER_UFS_PTABLE_H \ No newline at end of file