liblp: MetadataBuilder::HasBlockDevice

Query whether a block device is used in the metadata.

Test: pass
Bug: 118506262
Change-Id: I67196b68918ac232e735b10a850299f8653e4d3f
diff --git a/fs_mgr/liblp/builder.cpp b/fs_mgr/liblp/builder.cpp
index b6d6da1..38e0bcb 100644
--- a/fs_mgr/liblp/builder.cpp
+++ b/fs_mgr/liblp/builder.cpp
@@ -713,6 +713,11 @@
     return false;
 }
 
+bool MetadataBuilder::HasBlockDevice(const std::string& partition_name) const {
+    uint32_t index;
+    return FindBlockDeviceByName(partition_name, &index);
+}
+
 bool MetadataBuilder::GetBlockDeviceInfo(const std::string& partition_name,
                                          BlockDeviceInfo* info) const {
     uint32_t index;
diff --git a/fs_mgr/liblp/include/liblp/builder.h b/fs_mgr/liblp/include/liblp/builder.h
index 59717d1..297611b 100644
--- a/fs_mgr/liblp/include/liblp/builder.h
+++ b/fs_mgr/liblp/include/liblp/builder.h
@@ -248,6 +248,9 @@
     // false is returned.
     bool ImportPartitions(const LpMetadata& metadata, const std::set<std::string>& partition_names);
 
+    // Return true if a block device is found, else false.
+    bool HasBlockDevice(const std::string& partition_name) const;
+
   private:
     MetadataBuilder();
     MetadataBuilder(const MetadataBuilder&) = delete;