diff --git a/fs_mgr/liblp/builder.cpp b/fs_mgr/liblp/builder.cpp index 4406696ae..7e7f39370 100644 --- a/fs_mgr/liblp/builder.cpp +++ b/fs_mgr/liblp/builder.cpp @@ -1125,6 +1125,11 @@ void MetadataBuilder::SetAutoSlotSuffixing() { auto_slot_suffixing_ = true; } +void MetadataBuilder::SetVirtualABDeviceFlag() { + RequireExpandedMetadataHeader(); + header_.flags |= LP_HEADER_FLAG_VIRTUAL_AB_DEVICE; +} + bool MetadataBuilder::IsABDevice() { return !IPropertyFetcher::GetInstance()->GetProperty("ro.boot.slot_suffix", "").empty(); } diff --git a/fs_mgr/liblp/include/liblp/builder.h b/fs_mgr/liblp/include/liblp/builder.h index 7a334fbd9..851f04180 100644 --- a/fs_mgr/liblp/include/liblp/builder.h +++ b/fs_mgr/liblp/include/liblp/builder.h @@ -318,6 +318,8 @@ class MetadataBuilder { // Set the LP_METADATA_AUTO_SLOT_SUFFIXING flag. void SetAutoSlotSuffixing(); + // Set the LP_HEADER_FLAG_VIRTUAL_AB_DEVICE flag. + void SetVirtualABDeviceFlag(); // If set, checks for slot suffixes will be ignored internally. void IgnoreSlotSuffixing(); diff --git a/fs_mgr/liblp/include/liblp/metadata_format.h b/fs_mgr/liblp/include/liblp/metadata_format.h index 26cbf07ba..d3c98748d 100644 --- a/fs_mgr/liblp/include/liblp/metadata_format.h +++ b/fs_mgr/liblp/include/liblp/metadata_format.h @@ -224,8 +224,6 @@ typedef struct LpMetadataHeader { /* 128: See LP_HEADER_FLAG_ constants for possible values. Header flags are * independent of the version number and intended to be informational only. * New flags can be added without bumping the version. - * - * (Note there are no flags currently defined.) */ uint32_t flags; @@ -233,6 +231,11 @@ typedef struct LpMetadataHeader { uint8_t reserved[124]; } __attribute__((packed)) LpMetadataHeader; +/* This device uses Virtual A/B. Note that on retrofit devices, the expanded + * header may not be present. + */ +#define LP_HEADER_FLAG_VIRTUAL_AB_DEVICE 0x1 + /* This struct defines a logical partition entry, similar to what would be * present in a GUID Partition Table. */