Merge "Use target device mapper given mapper target" into main
This commit is contained in:
commit
191af79538
2 changed files with 8 additions and 4 deletions
|
@ -612,8 +612,12 @@ std::string DeviceMapper::GetTargetType(const struct dm_target_spec& spec) {
|
|||
|
||||
std::optional<std::string> ExtractBlockDeviceName(const std::string& path) {
|
||||
static constexpr std::string_view kDevBlockPrefix("/dev/block/");
|
||||
if (android::base::StartsWith(path, kDevBlockPrefix)) {
|
||||
return path.substr(kDevBlockPrefix.length());
|
||||
std::string real_path;
|
||||
if (!android::base::Realpath(path, &real_path)) {
|
||||
real_path = path;
|
||||
}
|
||||
if (android::base::StartsWith(real_path, kDevBlockPrefix)) {
|
||||
return real_path.substr(kDevBlockPrefix.length());
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
|
|
@ -52,8 +52,8 @@ enum class DmDeviceState { INVALID, SUSPENDED, ACTIVE };
|
|||
|
||||
static constexpr uint64_t kSectorSize = 512;
|
||||
|
||||
// Returns `path` without /dev/block prefix if and only if `path` starts with
|
||||
// that prefix.
|
||||
// Returns `path` without /dev/block prefix if `path` starts with that prefix.
|
||||
// Or, if `path` is a symlink, do the same with its real path.
|
||||
std::optional<std::string> ExtractBlockDeviceName(const std::string& path);
|
||||
|
||||
// This interface is for testing purposes. See DeviceMapper proper for what these methods do.
|
||||
|
|
Loading…
Reference in a new issue