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

Commit c24f7b82 authored by Bart Van Assche's avatar Bart Van Assche
Browse files

libdm: Export ExtractBlockDeviceName()



Make this function available to libdm users. A caller outside libdm will
be added by a later patch.

Bug: 194450129
Test: mm libfs_mgr libdm_test
Change-Id: I3e3560f3cdef8978eac644d5b53cf3851209c0c2
Signed-off-by: default avatarBart Van Assche <bvanassche@google.com>
parent 6b296db8
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -578,7 +578,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());
+4 −0
Original line number Diff line number Diff line
@@ -51,6 +51,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 {