Merge "libdm: Export ExtractBlockDeviceName()" into sc-dev

This commit is contained in:
TreeHugger Robot 2021-08-17 05:38:11 +00:00 committed by Android (Google) Code Review
commit de0cc6cc59
2 changed files with 5 additions and 1 deletions

View file

@ -560,7 +560,7 @@ std::string DeviceMapper::GetTargetType(const struct dm_target_spec& spec) {
return std::string{spec.target_type, sizeof(spec.target_type)};
}
static std::optional<std::string> ExtractBlockDeviceName(const std::string& path) {
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());

View file

@ -49,6 +49,10 @@ 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.
std::optional<std::string> ExtractBlockDeviceName(const std::string& path);
class DeviceMapper final {
public:
class DmBlockDevice final {