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

Commit 24a9789b authored by Jaegeuk Kim's avatar Jaegeuk Kim Committed by Automerger Merge Worker
Browse files

Merge "Use target device mapper given mapper target" into main am: 191af795

parents 2942157f 191af795
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -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 {};
}
+2 −2
Original line number Diff line number Diff line
@@ -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.