Loading fs_mgr/Android.bp +8 −0 Original line number Diff line number Diff line Loading @@ -149,6 +149,14 @@ cc_library_static { darwin: { enabled: false, }, vendor: { cflags: [ // Skipping entries in fstab should only be done in a system // process as the config file is in /system_ext. // Remove the op from the vendor variant. "-DNO_SKIP_MOUNT", ], }, }, export_include_dirs: ["include_fstab"], header_libs: [ Loading fs_mgr/fs_mgr_fstab.cpp +6 −0 Original line number Diff line number Diff line Loading @@ -690,7 +690,9 @@ bool ReadFstabFromFile(const std::string& path, Fstab* fstab) { TransformFstabForDsu(fstab, Split(lp_names, ",")); } #ifndef NO_SKIP_MOUNT SkipMountingPartitions(fstab); #endif EnableMandatoryFlags(fstab); return true; Loading Loading @@ -720,11 +722,14 @@ bool ReadFstabFromDt(Fstab* fstab, bool log) { return false; } #ifndef NO_SKIP_MOUNT SkipMountingPartitions(fstab); #endif return true; } #ifndef NO_SKIP_MOUNT // For GSI to skip mounting /product and /system_ext, until there are well-defined interfaces // between them and /system. Otherwise, the GSI flashed on /system might not be able to work with // device-specific /product and /system_ext. skip_mount.cfg belongs to system_ext partition because Loading Loading @@ -756,6 +761,7 @@ bool SkipMountingPartitions(Fstab* fstab) { return true; } #endif // Loads the fstab file and combines with fstab entries passed in from device tree. bool ReadDefaultFstab(Fstab* fstab) { Loading fs_mgr/liblp/builder.cpp +12 −5 Original line number Diff line number Diff line Loading @@ -204,13 +204,20 @@ std::unique_ptr<MetadataBuilder> MetadataBuilder::NewForUpdate(const IPartitionO } } if (IPropertyFetcher::GetInstance()->GetBoolProperty("ro.virtual_ab.enabled", false) && !always_keep_source_slot) { if (IPropertyFetcher::GetInstance()->GetBoolProperty("ro.virtual_ab.enabled", false)) { if (always_keep_source_slot) { // always_keep_source_slot implies the target build does not support snapshots. // Clear unsupported attributes. SetMetadataHeaderV0(metadata.get()); } else { // !always_keep_source_slot implies the target build supports snapshots. Do snapshot // updates. if (!UpdateMetadataForInPlaceSnapshot(metadata.get(), source_slot_number, target_slot_number)) { return nullptr; } } } return New(*metadata.get(), &opener); } Loading fs_mgr/liblp/include/liblp/builder.h +4 −2 Original line number Diff line number Diff line Loading @@ -209,8 +209,10 @@ class MetadataBuilder { // metadata may not have the target slot's devices listed yet, in which // case, it is automatically upgraded to include all available block // devices. // If |always_keep_source_slot| is set, on a Virtual A/B device, source slot // partitions are kept. This is useful when applying a downgrade package. // If |always_keep_source_slot| is set, on a Virtual A/B device // - source slot partitions are kept. // - UPDATED flag is cleared. // This is useful when applying a downgrade package. static std::unique_ptr<MetadataBuilder> NewForUpdate(const IPartitionOpener& opener, const std::string& source_partition, uint32_t source_slot_number, Loading fs_mgr/liblp/utility.cpp +39 −0 Original line number Diff line number Diff line Loading @@ -15,6 +15,7 @@ */ #include <fcntl.h> #include <inttypes.h> #include <stdint.h> #include <sys/stat.h> #include <unistd.h> Loading @@ -29,6 +30,7 @@ #include <vector> #include <android-base/file.h> #include <android-base/stringprintf.h> #include <ext4_utils/ext4_utils.h> #include <openssl/sha.h> Loading Loading @@ -285,5 +287,42 @@ bool UpdateMetadataForInPlaceSnapshot(LpMetadata* metadata, uint32_t source_slot return true; } inline std::string ToHexString(uint64_t value) { return android::base::StringPrintf("0x%" PRIx64, value); } void SetMetadataHeaderV0(LpMetadata* metadata) { if (metadata->header.minor_version <= LP_METADATA_MINOR_VERSION_MIN) { return; } LINFO << "Forcefully setting metadata header version " << LP_METADATA_MAJOR_VERSION << "." << metadata->header.minor_version << " to " << LP_METADATA_MAJOR_VERSION << "." << LP_METADATA_MINOR_VERSION_MIN; metadata->header.minor_version = LP_METADATA_MINOR_VERSION_MIN; metadata->header.header_size = sizeof(LpMetadataHeaderV1_0); // Retrofit Virtual A/B devices should have version 10.1, so flags shouldn't be set. // Warn if this is the case, but zero it out anyways. if (metadata->header.flags) { LWARN << "Zeroing unexpected flags: " << ToHexString(metadata->header.flags); } // Zero out all fields beyond LpMetadataHeaderV0. static_assert(sizeof(metadata->header) > sizeof(LpMetadataHeaderV1_0)); memset(reinterpret_cast<uint8_t*>(&metadata->header) + sizeof(LpMetadataHeaderV1_0), 0, sizeof(metadata->header) - sizeof(LpMetadataHeaderV1_0)); // Clear partition attributes unknown to V0. // On retrofit Virtual A/B devices, UPDATED flag may be set, so only log info here. for (auto& partition : metadata->partitions) { if (partition.attributes & ~LP_PARTITION_ATTRIBUTE_MASK_V0) { LINFO << "Clearing " << GetPartitionName(partition) << " partition attribute: " << ToHexString(partition.attributes); } partition.attributes &= LP_PARTITION_ATTRIBUTE_MASK_V0; } } } // namespace fs_mgr } // namespace android Loading
fs_mgr/Android.bp +8 −0 Original line number Diff line number Diff line Loading @@ -149,6 +149,14 @@ cc_library_static { darwin: { enabled: false, }, vendor: { cflags: [ // Skipping entries in fstab should only be done in a system // process as the config file is in /system_ext. // Remove the op from the vendor variant. "-DNO_SKIP_MOUNT", ], }, }, export_include_dirs: ["include_fstab"], header_libs: [ Loading
fs_mgr/fs_mgr_fstab.cpp +6 −0 Original line number Diff line number Diff line Loading @@ -690,7 +690,9 @@ bool ReadFstabFromFile(const std::string& path, Fstab* fstab) { TransformFstabForDsu(fstab, Split(lp_names, ",")); } #ifndef NO_SKIP_MOUNT SkipMountingPartitions(fstab); #endif EnableMandatoryFlags(fstab); return true; Loading Loading @@ -720,11 +722,14 @@ bool ReadFstabFromDt(Fstab* fstab, bool log) { return false; } #ifndef NO_SKIP_MOUNT SkipMountingPartitions(fstab); #endif return true; } #ifndef NO_SKIP_MOUNT // For GSI to skip mounting /product and /system_ext, until there are well-defined interfaces // between them and /system. Otherwise, the GSI flashed on /system might not be able to work with // device-specific /product and /system_ext. skip_mount.cfg belongs to system_ext partition because Loading Loading @@ -756,6 +761,7 @@ bool SkipMountingPartitions(Fstab* fstab) { return true; } #endif // Loads the fstab file and combines with fstab entries passed in from device tree. bool ReadDefaultFstab(Fstab* fstab) { Loading
fs_mgr/liblp/builder.cpp +12 −5 Original line number Diff line number Diff line Loading @@ -204,13 +204,20 @@ std::unique_ptr<MetadataBuilder> MetadataBuilder::NewForUpdate(const IPartitionO } } if (IPropertyFetcher::GetInstance()->GetBoolProperty("ro.virtual_ab.enabled", false) && !always_keep_source_slot) { if (IPropertyFetcher::GetInstance()->GetBoolProperty("ro.virtual_ab.enabled", false)) { if (always_keep_source_slot) { // always_keep_source_slot implies the target build does not support snapshots. // Clear unsupported attributes. SetMetadataHeaderV0(metadata.get()); } else { // !always_keep_source_slot implies the target build supports snapshots. Do snapshot // updates. if (!UpdateMetadataForInPlaceSnapshot(metadata.get(), source_slot_number, target_slot_number)) { return nullptr; } } } return New(*metadata.get(), &opener); } Loading
fs_mgr/liblp/include/liblp/builder.h +4 −2 Original line number Diff line number Diff line Loading @@ -209,8 +209,10 @@ class MetadataBuilder { // metadata may not have the target slot's devices listed yet, in which // case, it is automatically upgraded to include all available block // devices. // If |always_keep_source_slot| is set, on a Virtual A/B device, source slot // partitions are kept. This is useful when applying a downgrade package. // If |always_keep_source_slot| is set, on a Virtual A/B device // - source slot partitions are kept. // - UPDATED flag is cleared. // This is useful when applying a downgrade package. static std::unique_ptr<MetadataBuilder> NewForUpdate(const IPartitionOpener& opener, const std::string& source_partition, uint32_t source_slot_number, Loading
fs_mgr/liblp/utility.cpp +39 −0 Original line number Diff line number Diff line Loading @@ -15,6 +15,7 @@ */ #include <fcntl.h> #include <inttypes.h> #include <stdint.h> #include <sys/stat.h> #include <unistd.h> Loading @@ -29,6 +30,7 @@ #include <vector> #include <android-base/file.h> #include <android-base/stringprintf.h> #include <ext4_utils/ext4_utils.h> #include <openssl/sha.h> Loading Loading @@ -285,5 +287,42 @@ bool UpdateMetadataForInPlaceSnapshot(LpMetadata* metadata, uint32_t source_slot return true; } inline std::string ToHexString(uint64_t value) { return android::base::StringPrintf("0x%" PRIx64, value); } void SetMetadataHeaderV0(LpMetadata* metadata) { if (metadata->header.minor_version <= LP_METADATA_MINOR_VERSION_MIN) { return; } LINFO << "Forcefully setting metadata header version " << LP_METADATA_MAJOR_VERSION << "." << metadata->header.minor_version << " to " << LP_METADATA_MAJOR_VERSION << "." << LP_METADATA_MINOR_VERSION_MIN; metadata->header.minor_version = LP_METADATA_MINOR_VERSION_MIN; metadata->header.header_size = sizeof(LpMetadataHeaderV1_0); // Retrofit Virtual A/B devices should have version 10.1, so flags shouldn't be set. // Warn if this is the case, but zero it out anyways. if (metadata->header.flags) { LWARN << "Zeroing unexpected flags: " << ToHexString(metadata->header.flags); } // Zero out all fields beyond LpMetadataHeaderV0. static_assert(sizeof(metadata->header) > sizeof(LpMetadataHeaderV1_0)); memset(reinterpret_cast<uint8_t*>(&metadata->header) + sizeof(LpMetadataHeaderV1_0), 0, sizeof(metadata->header) - sizeof(LpMetadataHeaderV1_0)); // Clear partition attributes unknown to V0. // On retrofit Virtual A/B devices, UPDATED flag may be set, so only log info here. for (auto& partition : metadata->partitions) { if (partition.attributes & ~LP_PARTITION_ATTRIBUTE_MASK_V0) { LINFO << "Clearing " << GetPartitionName(partition) << " partition attribute: " << ToHexString(partition.attributes); } partition.attributes &= LP_PARTITION_ATTRIBUTE_MASK_V0; } } } // namespace fs_mgr } // namespace android