Merge "libdm: Export ExtractBlockDeviceName()" into sc-dev am: de0cc6cc59 am: b155a9a8a1
Original change: https://googleplex-android-review.googlesource.com/c/platform/system/core/+/15584613
Change-Id: Ib5046e3855f5c4249eed9676022a77aa93a1adce
diff --git a/fs_mgr/libdm/dm.cpp b/fs_mgr/libdm/dm.cpp
index 1414193..b1d5b39 100644
--- a/fs_mgr/libdm/dm.cpp
+++ b/fs_mgr/libdm/dm.cpp
@@ -578,7 +578,7 @@
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());
diff --git a/fs_mgr/libdm/include/libdm/dm.h b/fs_mgr/libdm/include/libdm/dm.h
index 8fcdf74..e6698ea 100644
--- a/fs_mgr/libdm/include/libdm/dm.h
+++ b/fs_mgr/libdm/include/libdm/dm.h
@@ -49,6 +49,10 @@
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 {