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

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

Change-Id: I1221648f11e6fd2ccae40b1ad5d335c31ff8efa1
diff --git a/fs_mgr/libdm/dm.cpp b/fs_mgr/libdm/dm.cpp
index 9a518c6..e43c00b 100644
--- a/fs_mgr/libdm/dm.cpp
+++ b/fs_mgr/libdm/dm.cpp
@@ -560,7 +560,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 70b14fa..bdbbf91 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 {