mirror of
https://gitee.com/openharmony/filemanagement_storage_service
synced 2024-11-27 09:10:33 +00:00
commit
27528899c4
@ -186,11 +186,14 @@ int DiskInfo::ReadPartition()
|
||||
LOGE("Invaild maxVolumes: %{public}d", maxVolumes);
|
||||
return E_ERR;
|
||||
}
|
||||
|
||||
int res = Destroy();
|
||||
if (res != E_OK) {
|
||||
LOGE("Destroy failed in ReadPartition");
|
||||
}
|
||||
|
||||
std::vector<std::string> cmd;
|
||||
std::vector<std::string> output;
|
||||
std::vector<std::string> lines;
|
||||
int res;
|
||||
|
||||
cmd.push_back(SGDISK_PATH);
|
||||
cmd.push_back(SGDISK_DUMP_CMD);
|
||||
|
@ -71,7 +71,7 @@ void DiskManager::HandleDiskEvent(NetlinkData *data)
|
||||
break;
|
||||
}
|
||||
case NetlinkData::Actions::CHANGE: {
|
||||
ChangeDisk(device);
|
||||
ChangeDisk(device, data);
|
||||
LOGI("Handle Disk Change Event");
|
||||
break;
|
||||
}
|
||||
@ -128,18 +128,25 @@ void DiskManager::CreateDisk(std::shared_ptr<DiskInfo> &diskInfo)
|
||||
LOGE("Create DiskInfo failed");
|
||||
return;
|
||||
}
|
||||
|
||||
disk_.push_back(diskInfo);
|
||||
}
|
||||
|
||||
void DiskManager::ChangeDisk(dev_t device)
|
||||
void DiskManager::ChangeDisk(dev_t device, NetlinkData *data)
|
||||
{
|
||||
for (auto &diskInfo : disk_) {
|
||||
if ((diskInfo != nullptr) && (diskInfo->GetDevice() == device)) {
|
||||
diskInfo->ReadMetadata();
|
||||
diskInfo->ReadPartition();
|
||||
return;
|
||||
}
|
||||
}
|
||||
auto diskInfo = MatchConfig(data);
|
||||
if (diskInfo == nullptr) {
|
||||
LOGI("Can't match config, devPath is %{public}s", data->GetDevpath().c_str());
|
||||
} else {
|
||||
CreateDisk(diskInfo);
|
||||
LOGI("Handle Disk Add Event");
|
||||
}
|
||||
}
|
||||
|
||||
void DiskManager::DestroyDisk(dev_t device)
|
||||
|
@ -197,13 +197,13 @@ HWTEST_F(DiskManagerTest, Storage_Service_DiskManagerTest_ChangeDisk_001, TestSi
|
||||
\0DEVPATH=/devices/platform/fe2b0000.dwmmc/*\0SUBSYSTEM=input\0SEQNUM=1064\0\
|
||||
\0PHYSDEVPATH=/devices/pci0000:00/0000:00:1d.1/usb2/2?2/2?2:1.0\0\
|
||||
\0PHYSDEVBUS=usb\0PHYSDEVDRIVER=usbhid\0MAJOR=13\0MINOR=34\0"};
|
||||
auto data = std::make_unique<NetlinkData>();
|
||||
data->Decode(msg);
|
||||
unsigned int major = std::stoi(data->GetParam("MAJOR"));
|
||||
unsigned int minor = std::stoi(data->GetParam("MINOR"));
|
||||
auto nlData = std::make_unique<NetlinkData>();
|
||||
nlData->Decode(msg);
|
||||
NetlinkData *data = nlData.get();
|
||||
unsigned int major = (unsigned int)std::stoi(data->GetParam("MAJOR"));
|
||||
unsigned int minor = (unsigned int)std::stoi(data->GetParam("MINOR"));
|
||||
dev_t device = makedev(major, minor);
|
||||
|
||||
diskManager->ChangeDisk(device);
|
||||
diskManager->ChangeDisk(device, data);
|
||||
|
||||
GTEST_LOG_(INFO) << "Storage_Service_DiskManagerTest_ChangeDisk_001 end";
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ public:
|
||||
virtual ~DiskManager();
|
||||
void CreateDisk(std::shared_ptr<DiskInfo> &diskInfo);
|
||||
void DestroyDisk(dev_t device);
|
||||
void ChangeDisk(dev_t device);
|
||||
void ChangeDisk(dev_t device, NetlinkData *data);
|
||||
std::shared_ptr<DiskInfo> GetDisk(dev_t device);
|
||||
void HandleDiskEvent(NetlinkData *data);
|
||||
int32_t HandlePartition(std::string diskId);
|
||||
|
Loading…
Reference in New Issue
Block a user