Lines Matching refs:name
61 bool DeviceMapper::CreateDevice(const std::string& name, const std::string& uuid) { in CreateDevice() argument
62 if (name.empty()) { in CreateDevice()
66 if (name.size() >= DM_NAME_LEN) { in CreateDevice()
67 LOG(ERROR) << "[" << name << "] is too long to be device mapper name"; in CreateDevice()
72 InitIo(&io, name); in CreateDevice()
78 PLOG(ERROR) << "DM_DEV_CREATE failed for [" << name << "]"; in CreateDevice()
84 CHECK(io.target_count == 0) << "Unexpected targets for newly created [" << name << "] device"; in CreateDevice()
85 CHECK(io.open_count == 0) << "Unexpected opens for newly created [" << name << "] device"; in CreateDevice()
91 bool DeviceMapper::DeleteDeviceIfExists(const std::string& name, in DeleteDeviceIfExists() argument
93 if (GetState(name) == DmDeviceState::INVALID) { in DeleteDeviceIfExists()
96 return DeleteDevice(name, timeout_ms); in DeleteDeviceIfExists()
99 bool DeviceMapper::DeleteDeviceIfExists(const std::string& name) { in DeleteDeviceIfExists() argument
100 return DeleteDeviceIfExists(name, 0ms); in DeleteDeviceIfExists()
103 bool DeviceMapper::DeleteDevice(const std::string& name, in DeleteDevice() argument
106 if (!GetDeviceUniquePath(name, &unique_path)) { in DeleteDevice()
107 LOG(ERROR) << "Failed to get unique path for device " << name; in DeleteDevice()
110 InitIo(&io, name); in DeleteDevice()
113 PLOG(ERROR) << "DM_DEV_REMOVE failed for [" << name << "]"; in DeleteDevice()
120 LOG(ERROR) << "Didn't generate uevent for [" << name << "] removal"; in DeleteDevice()
137 bool DeviceMapper::DeleteDevice(const std::string& name) { in DeleteDevice() argument
138 return DeleteDevice(name, 0ms); in DeleteDevice()
141 bool DeviceMapper::DeleteDeviceDeferred(const std::string& name) { in DeleteDeviceDeferred() argument
143 InitIo(&io, name); in DeleteDeviceDeferred()
147 PLOG(ERROR) << "DM_DEV_REMOVE with DM_DEFERRED_REMOVE failed for [" << name << "]"; in DeleteDeviceDeferred()
153 bool DeviceMapper::DeleteDeviceIfExistsDeferred(const std::string& name) { in DeleteDeviceIfExistsDeferred() argument
154 if (GetState(name) == DmDeviceState::INVALID) { in DeleteDeviceIfExistsDeferred()
157 return DeleteDeviceDeferred(name); in DeleteDeviceIfExistsDeferred()
174 bool DeviceMapper::CreateEmptyDevice(const std::string& name) { in CreateEmptyDevice() argument
176 return CreateDevice(name, uuid); in CreateEmptyDevice()
179 bool DeviceMapper::WaitForDevice(const std::string& name, in WaitForDevice() argument
185 if (!GetDeviceUniquePath(name, &unique_path) || !GetDmDevicePathByName(name, path)) { in WaitForDevice()
186 DeleteDevice(name); in WaitForDevice()
205 DeleteDevice(name); in WaitForDevice()
211 bool DeviceMapper::CreateDevice(const std::string& name, const DmTable& table, std::string* path, in CreateDevice() argument
213 if (!CreateEmptyDevice(name)) { in CreateDevice()
217 if (!LoadTableAndActivate(name, table)) { in CreateDevice()
218 DeleteDevice(name); in CreateDevice()
222 if (!WaitForDevice(name, timeout_ms, path)) { in CreateDevice()
223 DeleteDevice(name); in CreateDevice()
230 bool DeviceMapper::GetDeviceUniquePath(const std::string& name, std::string* path) { in GetDeviceUniquePath() argument
232 InitIo(&io, name); in GetDeviceUniquePath()
234 PLOG(ERROR) << "Failed to get device path: " << name; in GetDeviceUniquePath()
239 LOG(ERROR) << "Device does not have a unique path: " << name; in GetDeviceUniquePath()
246 bool DeviceMapper::GetDeviceNameAndUuid(dev_t dev, std::string* name, std::string* uuid) { in GetDeviceNameAndUuid() argument
256 if (name) { in GetDeviceNameAndUuid()
257 *name = io.name; in GetDeviceNameAndUuid()
265 std::optional<DeviceMapper::Info> DeviceMapper::GetDetailedInfo(const std::string& name) const { in GetDetailedInfo()
267 InitIo(&io, name); in GetDetailedInfo()
274 DmDeviceState DeviceMapper::GetState(const std::string& name) const { in GetState()
276 InitIo(&io, name); in GetState()
286 bool DeviceMapper::ChangeState(const std::string& name, DmDeviceState state) { in ChangeState() argument
292 InitIo(&io, name); in ChangeState()
304 bool DeviceMapper::CreateDevice(const std::string& name, const DmTable& table) { in CreateDevice() argument
306 if (!CreateDevice(name, table, &ignore_path, 0ms)) { in CreateDevice()
312 bool DeviceMapper::LoadTable(const std::string& name, const DmTable& table) { in LoadTable() argument
317 InitIo(io, name); in LoadTable()
331 bool DeviceMapper::LoadTableAndActivate(const std::string& name, const DmTable& table) { in LoadTableAndActivate() argument
332 if (!LoadTable(name, table)) { in LoadTableAndActivate()
337 InitIo(&io, name); in LoadTableAndActivate()
409 bool DeviceMapper::GetTargetByName(const std::string& name, DmTargetTypeInfo* info) { in GetTargetByName() argument
415 if (target.name() == name) { in GetTargetByName()
488 bool DeviceMapper::GetDmDevicePathByName(const std::string& name, std::string* path) { in GetDmDevicePathByName() argument
490 InitIo(&io, name); in GetDmDevicePathByName()
492 PLOG(WARNING) << "DM_DEV_STATUS failed for " << name; in GetDmDevicePathByName()
503 bool DeviceMapper::GetDmDeviceUuidByName(const std::string& name, std::string* uuid) { in GetDmDeviceUuidByName() argument
505 InitIo(&io, name); in GetDmDeviceUuidByName()
507 PLOG(WARNING) << "DM_DEV_STATUS failed for " << name; in GetDmDeviceUuidByName()
515 bool DeviceMapper::GetDeviceNumber(const std::string& name, dev_t* dev) { in GetDeviceNumber() argument
517 InitIo(&io, name); in GetDeviceNumber()
519 PLOG(WARNING) << "DM_DEV_STATUS failed for " << name; in GetDeviceNumber()
526 bool DeviceMapper::GetDeviceString(const std::string& name, std::string* dev) { in GetDeviceString() argument
528 if (!GetDeviceNumber(name, &num)) { in GetDeviceString()
535 bool DeviceMapper::GetTableStatus(const std::string& name, std::vector<TargetInfo>* table) { in GetTableStatus() argument
536 return GetTable(name, 0, table); in GetTableStatus()
539 bool DeviceMapper::GetTableInfo(const std::string& name, std::vector<TargetInfo>* table) { in GetTableInfo() argument
540 return GetTable(name, DM_STATUS_TABLE_FLAG, table); in GetTableInfo()
544 bool DeviceMapper::GetTable(const std::string& name, uint32_t flags, in GetTable() argument
552 InitIo(io, name); in GetTable()
557 PLOG(ERROR) << "DM_TABLE_STATUS failed for " << name; in GetTable()
587 void DeviceMapper::InitIo(struct dm_ioctl* io, const std::string& name) const { in InitIo()
596 if (!name.empty()) { in InitIo()
597 snprintf(io->name, sizeof(io->name), "%s", name.c_str()); in InitIo()
618 std::optional<std::string> name = ExtractBlockDeviceName(path); in IsDmBlockDevice() local
619 return name && android::base::StartsWith(*name, "dm-"); in IsDmBlockDevice()
623 std::optional<std::string> name = ExtractBlockDeviceName(path); in GetDmDeviceNameByPath() local
624 if (!name) { in GetDmDeviceNameByPath()
628 if (!android::base::StartsWith(*name, "dm-")) { in GetDmDeviceNameByPath()
632 std::string dm_name_file = "/sys/block/" + *name + "/dm/name"; in GetDmDeviceNameByPath()
643 std::optional<std::string> name = ExtractBlockDeviceName(path); in GetParentBlockDeviceByPath() local
644 if (!name) { in GetParentBlockDeviceByPath()
648 if (!android::base::StartsWith(*name, "dm-")) { in GetParentBlockDeviceByPath()
652 auto slaves_dir = "/sys/block/" + *name + "/slaves"; in GetParentBlockDeviceByPath()
734 bool DeviceMapper::CreatePlaceholderDevice(const std::string& name) { in CreatePlaceholderDevice() argument
735 if (!CreateEmptyDevice(name)) { in CreatePlaceholderDevice()
750 if (!LoadTable(name, table)) { in CreatePlaceholderDevice()