Arrange to delete the overlayfs backing when a specified partition
has been flashed.
Test: manual
Bug: 109821005
Bug: 117605276
Change-Id: I1c6a0341c6cd2ecfbb7c71bec5679a74d579aadd
This change introduces an IPartitionOpener abstraction. Methods that
interact with live metadata, such as ReadMetadata, UpdatePartitionTable,
and FlashPartitionTable, now require an IPartitionOpener object. Its
purpose is dependency injection: it will make these methods much easier
to test when the super partition spans multiple block devices.
All non-test consumers should be using PartitionOpener, and as such,
some helper methods have been added that automatically create one.
Bug: 116802789
Test: liblp_test gtest
device with super partition boots
Change-Id: I76725a5830ef643c5007c152c00ccaad8085151f
This patch removes the alignment, block device size, and starting sector
fields from LpGeometry into a new LpMetadataBlockDevice struct. The
metadata now contains a table of these structs, and the table will have
exactly one entry representing the super partition.
This refactoring will make it easier to have logical partitions span
multiple physical partitions. When that happens, the table will be
allowed to have more than one entry, and the first entry of the table
will be considered the "root" of the super partition.
Bug: 116802789
Test: liblp_test gtest
device with logical partitions flashes and boots
Change-Id: I97f23beac0363182cb6ae78ba2595860950afcf0
If fs_mgr_overlayfs_teardown is called with a specific mount_point
reference (eg: /vendor, /product, /system) when /mnt/scratch is not
mounted (eg: in recovery or fastboot mode), then mount it to perform
the directory teardown.
Test: manual on future changes: fastboot flash vendor -> fastbootd
Bug: 109821105
Bug: 117605276
Change-Id: I5735008e33b57d35345a799dc68bb43c9189135a
Provide a means to test out overlayfs work
Test: adb-remount-test.sh
Bug: 109821105
Bug: 117605276
Change-Id: Ia6114c8f4d0c3424cb869d002cc61cfc6863151c
These will help update_engine clear the target slot before applying an OTA.
Bug: 117182932
Test: liblp_test gtest
Change-Id: I6ad370e617f22f2098245a0028a93488f9ac8674
In preparation for supporting multiple block devices, this factors out
the free-list calculation for resizing partitions.
Additionally, it fixes a bug where space in between the first usable
sector and the first extent wasn't added to the free list.
Bug: 116802789
Test: liblp_test gtest
Change-Id: I965760eef0176020e9a5691ce1be2c8b5e0c8bc8
Switch to using a leading . to reference a teardown directory, and
if the top directory (/mnt/scratch/overlay) report ENOTEMPTY then
check if there is any non-hidden content, and if not then consider
removing the scratch partition.
Although not currently a problem, use basename of mount point in
fs_mgr_overlayfs_teardown_one when referencing the overlay directory
tree to match the setup behavior. Would have become a problem if
we started dealing with sub-mount points (eg: /vendor/firmware_mnt).
Test: manual
Bug: 109821105
Change-Id: I05dafe29c9e376e8423aedc8783fe674a657b3ee
Align the first usable sector to the logical block size, if no other
alignment was specified. This fixes a bunch of warnings during certain
gtests (ones with unaligned metadata sizes). The warnings were coming
from MetadataBuilder::GrowPartition() which expects the first sector
to always be block-aligned.
Bug: 116802789
Test: liblp_test gtest
Change-Id: I8dcf502aa4c2ba0674c5b4dcb77a274f300ff0a3
Traditionally the first 512 bytes of a partition can be interpreted as
an MBR. To prevent any compatibility issues, we explicitly zero the
first 4096 bytes of the super partition (one logical block, on most
systems).
Bug: 116802789
Test: liblp_test gtest
device with super partition flashes and boots
Change-Id: I29688ca75dbb52442f1464e8ab35893678a4f79e
The group_indices variable was intended to facilitate this, but I forgot
to actually use it.
Bug: 116817738
Test: lpmake, lpdump super_empty.img
Change-Id: Ia0da50b56b6c09e277324ec9d7aea6ce48fdc10a
If fs_mgr_overlayfs_teardown_one can not access the top directory,
then we should teardown the scratch volume.
Test: manual
Bug: 109821105
Change-Id: Ic86e10f1af1be354242fc004a95cac92d77619a6
Harden fs_mgr_overlayfs_mount_scratch to try alternate filesystem
mount type just in case (f2fs <-> ext4).
Cleanup remove any unnecessary string literals.
Test: manual
Bug: 109821105
Change-Id: I36ea974ffeeae392553fff779939dc76a12ab96e
If in fs_mgr_rm_all opendir on a subdirectory fails because of EPERM,
but a subsequent rmdir succeeds then there was no reason to report
the EPERM as an overall failure error code.
Test: manual
Bug: 117605276
Change-Id: I79fbf8567af1667094595e59ca2b536450f34b94
Now that backup metadata is stored at the start of the super partition,
this field is no longer needed. In actuality, it was not needed even
before then: both it and first_logical_sector exist for convenience,
since they can be re-derived at any time given an LpMetadataGeometry.
Bug: 116802789
Test: liblp_test gtest
device with dynamic partitions flashes and boots
Change-Id: I259a443097e689a0a9db7f822bbf1a52d40076dc
There's no reason to do this, since the fields are already in
LpMetadataGeometry. Removing this also simplifies multiple-block-device
support.
Bug: 116802789
Test: liblp_test gtest
Change-Id: Ib244a98fdd9d36c94a2dffd81bef68a1d5644ab9
Previously, metadata backups were stored at the end of the partition to
make them easy to locate. On older devices where the super partition
could span system/vendor partitions, we may want to leave the end of
each partition free to store an AVB footer. To allow this, we now store
geometry and metadata backups near the start of the partition instead.
They are still positioned at a fixed offset.
Bug: 116802789
Test: device boots after flashing new metadata
Change-Id: Ib173f251a4a13e290adcc4ac5cfbeb030eacda30
Note that this moves SparseBuilder into images.h, and splits
ReadLogicalPartitionGeometry into componenet methods for better
testability.
Bug: 116802789
Test: liblp_test gtest
Change-Id: Ib41a46b633c71623c136a10fcc8017e4de20884c
fs_mgr_update_verity_state() provides the needed result, we do not
need to check verity state manually.
Caveat:
The open-coded verity check is not 100% redundant, as it ensures
that if /vendor is not mounted, where the device mount table resides
to aid in a correct enumeration of all verity-enabled mount points,
that /system is not accidentally overlay mounted on a verity checked
volume. This is a unlikely corner condition. A fix for this
condition in the future is to instead migrate this redundant
checking into fs_mgr_update_verity_state() since system is
considered ever present and can be blindly performed without the
required /system or / mount point entries in fstab. Note that
the overlay logic is #ifdef'd out on user builds, so it is not
really a security or reliability issue on a release build.
Test: manual
Bug: 109821005
Change-Id: Ib4a7f9438b2a3cb008e263605a7a7647737c40f2
If there is a "/" in the fstab, can only be there on system as root.
This drops the troubling and annoying log message:
[libfs_mgr]Could not find verity device for mount point: /: No such device or address
Test: manual
Bug: 109821005
Change-Id: I6bbfc0af63e1526e52a1c6365241dbc1d5ee7c6a
The default is a valid /mnt/scratch/overlay/ or /cache/overlay/
directory, with .../<mount_point>/upper and .../<mount_point>/work,
associated with each system partition <mount_point>. Add support
for Dynamically Resized Partitions to create /mnt/scratch.
Test: manual
Bug: 109821005
Change-Id: I5e3f66778ea9e937c839e25541fedb6fbf34ab50
Stop checking verity on each entry in the fstab, collect the verity
list whole and use in the loop. Open code verity detection for
"system" for cases where device table is incompletely specified, does
not specify a "/" or a "/system" entry.
Test: manual, /system on system-as-root overlays correctly.
Bug: 109821005
Change-Id: I7bc5fbef6577bb0823cb5deb26c370219e4e597b
if we specify mount_point /vendor, candidate list should not add
/system as a candidate. eg: adb disable-verity /vendor.
Test: manual
Bug: 109821005
Change-Id: Id4d9ee617262cf1b68a790c9c43476d0f907353a
Added fs_mgr_overlayfs_required_devices() as hint to init to make sure
the device gets created before fs_mgr_overlayfs_mount_all().
Test: manual
Bug: 109821005
Change-Id: Iab038f3e0252a357b082bb08db3679512b9badec