diff --git a/fs_mgr/liblp/images.cpp b/fs_mgr/liblp/images.cpp index db27022db..58a88b58e 100644 --- a/fs_mgr/liblp/images.cpp +++ b/fs_mgr/liblp/images.cpp @@ -89,8 +89,8 @@ bool WriteToImageFile(int fd, const LpMetadata& input) { return true; } -bool WriteToImageFile(const char* file, const LpMetadata& input) { - unique_fd fd(open(file, O_CREAT | O_RDWR | O_TRUNC | O_CLOEXEC, 0644)); +bool WriteToImageFile(const std::string& file, const LpMetadata& input) { + unique_fd fd(open(file.c_str(), O_CREAT | O_RDWR | O_TRUNC | O_CLOEXEC, 0644)); if (fd < 0) { PERROR << __PRETTY_FUNCTION__ << " open failed: " << file; return false; @@ -149,8 +149,8 @@ bool ImageBuilder::IsValid() const { return device_images_.size() == metadata_.block_devices.size(); } -bool ImageBuilder::Export(const char* file) { - unique_fd fd(open(file, O_CREAT | O_RDWR | O_TRUNC | O_CLOEXEC, 0644)); +bool ImageBuilder::Export(const std::string& file) { + unique_fd fd(open(file.c_str(), O_CREAT | O_RDWR | O_TRUNC | O_CLOEXEC, 0644)); if (fd < 0) { PERROR << "open failed: " << file; return false; @@ -438,7 +438,7 @@ int ImageBuilder::OpenImageFile(const std::string& file) { return temp_fds_.back().get(); } -bool WriteToImageFile(const char* file, const LpMetadata& metadata, uint32_t block_size, +bool WriteToImageFile(const std::string& file, const LpMetadata& metadata, uint32_t block_size, const std::map& images, bool sparsify) { ImageBuilder builder(metadata, block_size, images, sparsify); return builder.IsValid() && builder.Build() && builder.Export(file); diff --git a/fs_mgr/liblp/images.h b/fs_mgr/liblp/images.h index 75060f9d7..a284d2ef6 100644 --- a/fs_mgr/liblp/images.h +++ b/fs_mgr/liblp/images.h @@ -41,7 +41,7 @@ class ImageBuilder { const std::map& images, bool sparsify); bool Build(); - bool Export(const char* file); + bool Export(const std::string& file); bool ExportFiles(const std::string& dir); bool IsValid() const; diff --git a/fs_mgr/liblp/include/liblp/liblp.h b/fs_mgr/liblp/include/liblp/liblp.h index 5f782b0ad..d3a7b936f 100644 --- a/fs_mgr/liblp/include/liblp/liblp.h +++ b/fs_mgr/liblp/include/liblp/liblp.h @@ -72,9 +72,9 @@ std::unique_ptr ReadMetadata(const std::string& super_partition, uin // Read/Write logical partition metadata to an image file, for diagnostics or // flashing. -bool WriteToImageFile(const char* file, const LpMetadata& metadata, uint32_t block_size, +bool WriteToImageFile(const std::string& file, const LpMetadata& metadata, uint32_t block_size, const std::map& images, bool sparsify); -bool WriteToImageFile(const char* file, const LpMetadata& metadata); +bool WriteToImageFile(const std::string& file, const LpMetadata& metadata); std::unique_ptr ReadFromImageFile(const std::string& image_file); std::unique_ptr ReadFromImageBlob(const void* data, size_t bytes);