Loading fs_mgr/fs_mgr_dm_linear.cpp +4 −0 Original line number Diff line number Diff line Loading @@ -151,6 +151,10 @@ bool CreateLogicalPartitions(const LpMetadata& metadata, const std::string& supe LINFO << "Skipping zero-length logical partition: " << GetPartitionName(partition); continue; } if (partition.attributes & LP_PARTITION_ATTR_DISABLED) { LINFO << "Skipping disabled partition: " << GetPartitionName(partition); continue; } params.partition = &partition; Loading fs_mgr/libfiemap/binder.cpp +17 −0 Original line number Diff line number Diff line Loading @@ -43,6 +43,8 @@ class ImageManagerBinder final : public IImageManager { std::string* dev) override; bool ZeroFillNewImage(const std::string& name, uint64_t bytes) override; bool RemoveAllImages() override; bool DisableImage(const std::string& name) override; bool RemoveDisabledImages() override; std::vector<std::string> GetAllBackingImages() override; Loading Loading @@ -163,6 +165,21 @@ bool ImageManagerBinder::RemoveAllImages() { return true; } bool ImageManagerBinder::DisableImage(const std::string&) { LOG(ERROR) << __PRETTY_FUNCTION__ << " is not available over binder"; return false; } bool ImageManagerBinder::RemoveDisabledImages() { auto status = manager_->removeDisabledImages(); if (!status.isOk()) { LOG(ERROR) << __PRETTY_FUNCTION__ << " binder returned: " << status.exceptionMessage().string(); return false; } return true; } static android::sp<IGsid> AcquireIGsid(const std::chrono::milliseconds& timeout_ms) { if (android::base::GetProperty("init.svc.gsid", "") != "running") { if (!android::base::SetProperty("ctl.start", "gsid") || Loading fs_mgr/libfiemap/image_manager.cpp +21 −0 Original line number Diff line number Diff line Loading @@ -632,6 +632,27 @@ bool ImageManager::Validate() { return true; } bool ImageManager::DisableImage(const std::string& name) { return AddAttributes(metadata_dir_, name, LP_PARTITION_ATTR_DISABLED); } bool ImageManager::RemoveDisabledImages() { if (!MetadataExists(metadata_dir_)) { return true; } auto metadata = OpenMetadata(metadata_dir_); if (!metadata) { return false; } bool ok = true; for (const auto& partition : metadata->partitions) { ok &= DeleteBackingImage(GetPartitionName(partition)); } return ok; } std::unique_ptr<MappedDevice> MappedDevice::Open(IImageManager* manager, const std::chrono::milliseconds& timeout_ms, const std::string& name) { Loading fs_mgr/libfiemap/image_test.cpp +8 −0 Original line number Diff line number Diff line Loading @@ -112,6 +112,14 @@ TEST_F(NativeTest, CreateAndMap) { ASSERT_EQ(android::base::GetProperty(PropertyName(), ""), ""); } TEST_F(NativeTest, DisableImage) { ASSERT_TRUE(manager_->CreateBackingImage(base_name_, kTestImageSize, false, nullptr)); ASSERT_TRUE(manager_->BackingImageExists(base_name_)); ASSERT_TRUE(manager_->DisableImage(base_name_)); ASSERT_TRUE(manager_->RemoveDisabledImages()); ASSERT_TRUE(!manager_->BackingImageExists(base_name_)); } // This fixture is for tests against a simulated device environment. Rather // than use /data, we create an image and then layer a new filesystem within // it. Each test then decides how to mount and create layered images. This Loading fs_mgr/libfiemap/include/libfiemap/image_manager.h +12 −0 Original line number Diff line number Diff line Loading @@ -84,6 +84,16 @@ class IImageManager { virtual bool MapImageWithDeviceMapper(const IPartitionOpener& opener, const std::string& name, std::string* dev) = 0; // Mark an image as disabled. This is useful for marking an image as // will-be-deleted in recovery, since recovery cannot mount /data. // // This is not available in binder, since it is intended for recovery. // When binder is available, images can simply be removed. virtual bool DisableImage(const std::string& name) = 0; // Remove all images that been marked as disabled. virtual bool RemoveDisabledImages() = 0; // Get all backing image names. virtual std::vector<std::string> GetAllBackingImages() = 0; Loading Loading @@ -119,6 +129,8 @@ class ImageManager final : public IImageManager { bool MapImageWithDeviceMapper(const IPartitionOpener& opener, const std::string& name, std::string* dev) override; bool RemoveAllImages() override; bool DisableImage(const std::string& name) override; bool RemoveDisabledImages() override; std::vector<std::string> GetAllBackingImages(); // Same as CreateBackingImage, but provides a progress notification. Loading Loading
fs_mgr/fs_mgr_dm_linear.cpp +4 −0 Original line number Diff line number Diff line Loading @@ -151,6 +151,10 @@ bool CreateLogicalPartitions(const LpMetadata& metadata, const std::string& supe LINFO << "Skipping zero-length logical partition: " << GetPartitionName(partition); continue; } if (partition.attributes & LP_PARTITION_ATTR_DISABLED) { LINFO << "Skipping disabled partition: " << GetPartitionName(partition); continue; } params.partition = &partition; Loading
fs_mgr/libfiemap/binder.cpp +17 −0 Original line number Diff line number Diff line Loading @@ -43,6 +43,8 @@ class ImageManagerBinder final : public IImageManager { std::string* dev) override; bool ZeroFillNewImage(const std::string& name, uint64_t bytes) override; bool RemoveAllImages() override; bool DisableImage(const std::string& name) override; bool RemoveDisabledImages() override; std::vector<std::string> GetAllBackingImages() override; Loading Loading @@ -163,6 +165,21 @@ bool ImageManagerBinder::RemoveAllImages() { return true; } bool ImageManagerBinder::DisableImage(const std::string&) { LOG(ERROR) << __PRETTY_FUNCTION__ << " is not available over binder"; return false; } bool ImageManagerBinder::RemoveDisabledImages() { auto status = manager_->removeDisabledImages(); if (!status.isOk()) { LOG(ERROR) << __PRETTY_FUNCTION__ << " binder returned: " << status.exceptionMessage().string(); return false; } return true; } static android::sp<IGsid> AcquireIGsid(const std::chrono::milliseconds& timeout_ms) { if (android::base::GetProperty("init.svc.gsid", "") != "running") { if (!android::base::SetProperty("ctl.start", "gsid") || Loading
fs_mgr/libfiemap/image_manager.cpp +21 −0 Original line number Diff line number Diff line Loading @@ -632,6 +632,27 @@ bool ImageManager::Validate() { return true; } bool ImageManager::DisableImage(const std::string& name) { return AddAttributes(metadata_dir_, name, LP_PARTITION_ATTR_DISABLED); } bool ImageManager::RemoveDisabledImages() { if (!MetadataExists(metadata_dir_)) { return true; } auto metadata = OpenMetadata(metadata_dir_); if (!metadata) { return false; } bool ok = true; for (const auto& partition : metadata->partitions) { ok &= DeleteBackingImage(GetPartitionName(partition)); } return ok; } std::unique_ptr<MappedDevice> MappedDevice::Open(IImageManager* manager, const std::chrono::milliseconds& timeout_ms, const std::string& name) { Loading
fs_mgr/libfiemap/image_test.cpp +8 −0 Original line number Diff line number Diff line Loading @@ -112,6 +112,14 @@ TEST_F(NativeTest, CreateAndMap) { ASSERT_EQ(android::base::GetProperty(PropertyName(), ""), ""); } TEST_F(NativeTest, DisableImage) { ASSERT_TRUE(manager_->CreateBackingImage(base_name_, kTestImageSize, false, nullptr)); ASSERT_TRUE(manager_->BackingImageExists(base_name_)); ASSERT_TRUE(manager_->DisableImage(base_name_)); ASSERT_TRUE(manager_->RemoveDisabledImages()); ASSERT_TRUE(!manager_->BackingImageExists(base_name_)); } // This fixture is for tests against a simulated device environment. Rather // than use /data, we create an image and then layer a new filesystem within // it. Each test then decides how to mount and create layered images. This Loading
fs_mgr/libfiemap/include/libfiemap/image_manager.h +12 −0 Original line number Diff line number Diff line Loading @@ -84,6 +84,16 @@ class IImageManager { virtual bool MapImageWithDeviceMapper(const IPartitionOpener& opener, const std::string& name, std::string* dev) = 0; // Mark an image as disabled. This is useful for marking an image as // will-be-deleted in recovery, since recovery cannot mount /data. // // This is not available in binder, since it is intended for recovery. // When binder is available, images can simply be removed. virtual bool DisableImage(const std::string& name) = 0; // Remove all images that been marked as disabled. virtual bool RemoveDisabledImages() = 0; // Get all backing image names. virtual std::vector<std::string> GetAllBackingImages() = 0; Loading Loading @@ -119,6 +129,8 @@ class ImageManager final : public IImageManager { bool MapImageWithDeviceMapper(const IPartitionOpener& opener, const std::string& name, std::string* dev) override; bool RemoveAllImages() override; bool DisableImage(const std::string& name) override; bool RemoveDisabledImages() override; std::vector<std::string> GetAllBackingImages(); // Same as CreateBackingImage, but provides a progress notification. Loading