Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 19d88c7e authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

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

Original change: https://googleplex-android-review.googlesource.com/c/platform/system/core/+/15584613

Change-Id: Ib5141f5c382cfce3387aadc4b526d11f5b3fdae3
parents fca601aa de0cc6cc
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -560,7 +560,7 @@ std::string DeviceMapper::GetTargetType(const struct dm_target_spec& spec) {
    return std::string{spec.target_type, sizeof(spec.target_type)};
    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/");
    static constexpr std::string_view kDevBlockPrefix("/dev/block/");
    if (android::base::StartsWith(path, kDevBlockPrefix)) {
    if (android::base::StartsWith(path, kDevBlockPrefix)) {
        return path.substr(kDevBlockPrefix.length());
        return path.substr(kDevBlockPrefix.length());
+4 −0
Original line number Original line Diff line number Diff line
@@ -49,6 +49,10 @@ enum class DmDeviceState { INVALID, SUSPENDED, ACTIVE };


static constexpr uint64_t kSectorSize = 512;
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 {
class DeviceMapper final {
  public:
  public:
    class DmBlockDevice final {
    class DmBlockDevice final {