Loading fs_mgr/libdm/dm.cpp +6 −2 Original line number Diff line number Diff line Loading @@ -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 {}; } Loading fs_mgr/libdm/include/libdm/dm.h +2 −2 Original line number Diff line number Diff line Loading @@ -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 Loading
fs_mgr/libdm/dm.cpp +6 −2 Original line number Diff line number Diff line Loading @@ -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 {}; } Loading
fs_mgr/libdm/include/libdm/dm.h +2 −2 Original line number Diff line number Diff line Loading @@ -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