Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 272ef868 authored by Alessio Balsini's avatar Alessio Balsini
Browse files

Extra logging for metadata errors



Increase logging in metadata image management.

Bug: none
Test: m
Change-Id: Ie49ca9ac90cd593c95d31f4651ae724d617d5695
Signed-off-by: default avatarAlessio Balsini <balsini@google.com>
parent 09b9fc56
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -252,7 +252,7 @@ bool ImageManager::DeleteBackingImage(const std::string& name) {
    // For dm-linear devices sitting on top of /data, we cannot risk deleting
    // the file. The underlying blocks could be reallocated by the filesystem.
    if (IsImageMapped(name)) {
        LOG(ERROR) << "Backing image " << name << " is currently mapped to a block device";
        LOG(ERROR) << "Cannot delete backing image " << name << " because mapped to a block device";
        return false;
    }

+14 −3
Original line number Diff line number Diff line
@@ -39,7 +39,13 @@ std::string GetMetadataFile(const std::string& metadata_dir) {

bool MetadataExists(const std::string& metadata_dir) {
    auto metadata_file = GetMetadataFile(metadata_dir);
    return access(metadata_file.c_str(), F_OK) == 0;
    if (access(metadata_file.c_str(), F_OK)) {
        if (errno != ENOENT) {
            PLOG(ERROR) << "Access " << metadata_file << " failed:";
        }
        return false;
    }
    return true;
}

std::unique_ptr<LpMetadata> OpenMetadata(const std::string& metadata_dir) {
@@ -61,7 +67,7 @@ std::unique_ptr<MetadataBuilder> OpenOrCreateMetadata(const std::string& metadat
    std::unique_ptr<MetadataBuilder> builder;
    if (access(metadata_file.c_str(), R_OK)) {
        if (errno != ENOENT) {
            PLOG(ERROR) << "access " << metadata_file << " failed:";
            PLOG(ERROR) << "Access " << metadata_file << " failed:";
            return nullptr;
        }

@@ -112,7 +118,12 @@ bool SaveMetadata(MetadataBuilder* builder, const std::string& metadata_dir) {

bool RemoveAllMetadata(const std::string& dir) {
    auto metadata_file = GetMetadataFile(dir);
    return android::base::RemoveFileIfExists(metadata_file);
    std::string err;
    if (!android::base::RemoveFileIfExists(metadata_file, &err)) {
        LOG(ERROR) << "Could not remove metadata file: " << err;
        return false;
    }
    return true;
}

bool FillPartitionExtents(MetadataBuilder* builder, Partition* partition, SplitFiemap* file,