Commit graph

955 commits

Author SHA1 Message Date
David Anderson
d25f1c3775 fastbootd: Support two super partitions for retrofit devices.
Retrofit devices will have two super partitions, spanning the A and B
slots separately. By design an OTA will never cause "A" or "B"
partitions to be assigned to the wrong super. However, the same is not
true of fastbootd, where it is possible to flash the inactive slot. We
do not want, for example, logical "system_a" flashing to super_b.

When interacting with partitions, fastbootd now extracts the slot suffix
from a GetSuperSlotSuffix() helper. On retrofit devices, if the partition
name has a slot, that slot will override FastbootDevice::GetCurrentSlot.
This forces partitions in the inactive slot to be assigned to the correct
super.

There are two consequences of this. First, partitions with no slot
suffix will default to the current slot. That means it is possible to
wind up with two "scratch" partitions, if "adb remount" is used on both
the "A" and "B" slots. However, only the active slot's "scratch" will be
visible to the user (either through adb or fastboot).

Second, if one slot does not have dynamic partitions, flashing will
default to fixed partitions. For example, if the A slot is logical and B
is not, flashing "system_a" will be logical and "system_b" will be
fixed. This works no matter which slot is active. We do not try to
upgrade the inactive slot to dynamic partitions.

Bug: 116802789
Test: fastboot set_active a
      fastboot flashall # dynamic partitions
      fastboot getvar is-logical:system_a # true
      fastboot getvar is-logical:system_b # false
      fastboot set_active b
      fastboot flashall --skip-secondary
      fastboot getvar is-logical:system_a # true
      fastboot getvar is-logical:system_b # true
      Booting both slots works.

Change-Id: Ib3c91944aaee1a96b2f5ad69c90e215bd6c5a2e8
2018-11-20 13:47:01 -08:00
David Anderson
eb1213f170 Merge "liblp: Auto-suffix group names." 2018-11-19 22:37:33 +00:00
David Anderson
7256eaa1b4 liblp: Auto-suffix group names.
This is needed for update_engine to properly clean old partitions on
retrofit devices.

Bug: 119687874
Test: liblp_test gtest
Change-Id: Ida9483ad3c127e357f45789540ebbedc9d3d3883
2018-11-19 11:20:09 -08:00
Treehugger Robot
8995970ce3 Merge "fs_mgr: remove by_name_symlinks_map_ from AvpOps" 2018-11-19 05:56:36 +00:00
Yifan Hong
6af857f21d Merge "liblp: MetadataBuilder::HasBlockDevice" 2018-11-16 23:14:38 +00:00
Mark Salyzyn
271485feba fs_mgr: overlayfs: test: adding diagnostic value
Add a test report df before overlay applied to make it clearer what
the device looked like before applying for remount.  Check error
code from adb disable-verity and use that to terminate test if bad.
Collect a sliced logcat for failures to help diagnose problems.
If the device does not come back after flashing, timeout and fail
when waiting.  Fix some issues that result when running script under
set -x when diagnosing the tests logistics.

Test: adb-remount-test.sh
Bug: 109821005
Change-Id: Iffbd6261703393417cb6ec3a12042d59523c348d
2018-11-15 23:02:29 +00:00
Mark Salyzyn
0733a86990 fs_mgr: overlayfs: test: skip apex mounts
Strip out /dev/block/loop* devices to filter out apex mounts.  Deal
with scale of skip_administrative_mounts function to make for easier
maintenance.

Test: adb-remount-test.sh
Bug: 109821005
Bug: 112455435
Change-Id: Ic7382a613db8f3ac7cdc10721194042378d136b9
2018-11-15 23:01:27 +00:00
Yifan Hong
dca3b3bb2c liblp: MetadataBuilder::HasBlockDevice
Query whether a block device is used in the metadata.

Test: pass
Bug: 118506262
Change-Id: I67196b68918ac232e735b10a850299f8653e4d3f
2018-11-15 14:45:41 -08:00
Treehugger Robot
5729cff611 Merge "liblp: partition_opener: fix log; more logs" 2018-11-15 02:01:34 +00:00
Yifan Hong
098cc974de liblp: partition_opener: fix log; more logs
Test: manual
Change-Id: I48777a479651dbd389e0a4420505342cb272b9f2
2018-11-14 22:45:20 +00:00
David Anderson
a14f111377 liblp: Use TMPDIR instead of P_tmpdir.
lpmake should be using the intermediates directory for temporary work
rather than /tmp.  Add ability to respect TMPDIR environment as
inherited from TemporaryFile.

Bug: 119313545
Test: manual test
Change-Id: I1a0317538875ee37fb4066602ff7a75e4658d74b
2018-11-14 12:52:23 -08:00
Treehugger Robot
af4a0e846e Merge "liblp: SparseBuilder: num_blocks aren't check correctly" 2018-11-14 06:57:46 +00:00
Yifan Hong
6ddf9683a1 liblp: fix error message
Test: pass
Change-Id: I5a969c3fbabd8f32ea785a6196225e655205245b
2018-11-13 13:58:27 -08:00
Yifan Hong
27a34d71c1 liblp: SparseBuilder: num_blocks aren't check correctly
Test: builds

Change-Id: Ic0fe481cd168217d764b7c69dfe9da124a277f82
2018-11-13 12:57:44 -08:00
Tom Cherry
9856460763 fs_mgr: remove by_name_symlinks_map_ from AvpOps
With the addition of the /dev/block/by-name/ symlinks created for the
boot_device, we no longer need to use a map to track the symlinks for
the partitions AVB needs to access.

This will help us in removing the requirement to specify which
partitions contain AVB metadata.

Bug: 117933812
Test: boot blueline_mainline with AVB
Change-Id: I1d46dba5b2fc16b2a14f861b34225ac0f2995b60
2018-11-13 11:37:36 -08:00
Tom Cherry
877e074eaf Merge "fs_mgr: remove same partition check for vbmeta" 2018-11-13 00:40:24 +00:00
David Anderson
140d053c02 liblp: Add a helper method for upgrading metadata on retrofit devices.
This adds a new MetadataBuilder constructor, NewForUpdate, that can be
used by update_engine to simplify upgrading metadata. It is safe to call
whether or not the device is a retrofit. If the metadata has block
devices assigned to a specific slot, and that slot matches the slot
suffix, it will ensure that an equivalent entry exists for the alternate
slot.

Thus, if the source slot is _a and the target slot is _b, and the
metadata has "system_a" as a block device but not "system_b", this will
automatically add "system_b" as a block device.

Bug: 116802789
Test: liblp_test gtest
Change-Id: Ie89d4dbf4c708b5705e658220227ebf33fcb1930
2018-11-09 16:03:40 -08:00
Tom Cherry
1bc8dcd92f fs_mgr: remove same partition check for vbmeta
With chained vbmeta and especially its use with dynamic partitions,
this check is no longer always true.  A concrete example is the
chained vbmeta_system partition that contains the metadata for /system
and /product_services for mainline devices.

Test: blueline_mainline boots with AVB enabled
Change-Id: Ib4115831bb3bb49bf6d2a908df59ba32f8405de7
2018-11-09 10:13:13 -08:00
David Anderson
3d08636934 liblp: Fix io_tests.
These broke after recent changes to use IPartitionOpener in more places.
The io_tests must now give block device info to TestPartitionOpener.

Bug: N/A
Test: liblp_test gtest
Change-Id: I0a6505c7223e74507dc13184069fdc34bb6b81e4
2018-11-08 19:04:05 -08:00
David Anderson
7165154334 liblp: Split super.img for retrofit devices.
On retrofit devices, we need images that can be flashed in the
bootloader for the component "super"partitions. This change rewrites
SparseBuilder so that it generates one sparse image per block device,
and now handles partitions that span across multiple block devices.

A new API function has been added to write the set of sparse images to
an output folder.

Bug: 118887112
Test: manual test, flash split images
Change-Id: Iff56efdcb7bdfd5bc8dd7ff44e8234e091ac2346
2018-11-08 14:19:42 -08:00
David Anderson
76cde4173a liblp: Allow automatic slot suffixing of partition names.
On retrofit devices, an OTA package or super_empty.img won't know which
slot it applies to. This is not an issue on devices shipping with
dynamic partitions, since they ship on the "a" slot.

To work around this, partitions and block devices can be flagged as
"auto-slot-suffixed". This indicates that ReadMetadata should
automatically append a slot suffix before returning the metadata. This
flag is added by MetadataBuilder when requested, and will be enabled via
lpmake separately.

After ReadMetadata has applied slot suffixes, it takes care to remove
the slot-suffix flag. This prevents the suffix from being applied twice,
if for example the metadata is then imported into a MetadataBuilder.

Bug: 116802789
Test: liblp_test gtest
      retrofit device boots

Change-Id: Ic7de06d31253a8d5b8d15c0d936175ca2939f857
2018-11-08 09:51:03 -08:00
Mark Salyzyn
6a11694c1b fs_mgr: overlayfs earlier kernels do not need override_creds=off
Kernels at or older than 4.6, the overlayfs drivers do not need,
or support, override_creds=off.  Drop using the mount option.

Commit 3fe6e52f062643676eb4518d68cee3bc1272091b introduced the
need for override_creds=off, and none of the kernels that contain
this patch without the patch that introduces override_creds can
be used with Android.

Test: compile
Bug: 118882257
Bug: 109821005
Change-Id: I832c8ca3fce0269bdef4ce988541adb7ba9662ed
2018-11-07 11:05:18 -08:00
David Anderson
a97d6e36d5 Merge "fastboot: Query the name of the super partition." 2018-11-06 22:59:17 +00:00
Treehugger Robot
7d87981f79 Merge "adb: overlayfs failed to remount /system" 2018-11-06 22:49:45 +00:00
Treehugger Robot
d016c75104 Merge "fastboot: Fix flashing both slots with dynamic partitions." 2018-11-06 22:48:45 +00:00
Treehugger Robot
612c2854ad Merge "fs_mgr: enable DT fstab based on its status node appropriately" 2018-11-06 20:30:44 +00:00
David Anderson
88fd7e60d0 Merge "liblp: Fix flashing metadata to multiple block devices." 2018-11-06 19:45:26 +00:00
David Anderson
90fe0a43ab fastboot: Query the name of the super partition.
This patch adds a new variable, "super-partition-name", to query the
name of the super partition (with a slot suffix if it has one). The
fastboot flashing tool has been updated to query this variable.

Since the super partition name can no longer be determined without
fastbootd, the presence of super_empty.img is used to test for
dynamic partition support rather than the presence of a super partition.

Bug: 116802789
Test: fastboot flashall on retrofit device
Change-Id: If830768eba6de7f31ac3183c64167fae973c77a4
2018-11-06 11:43:04 -08:00
David Anderson
96a9fd4063 fastboot: Fix flashing both slots with dynamic partitions.
When updating the super partition, attempt to preserve partitions from
the other slot. If any partition can't be preserved, fail and require a
wipe (-w) to proceed. This allows two bootable builds to be flashed to
both slots.

The preserve operation can fail if the metadata is not compatible with
the old partition layout. For example, if the partition references a
group that no longer exists, or a group changed its capacity, or the
metadata's block device list or list contents changed.

Bug: N/A
Test: liblp_test gtest
      fastboot flashall --skip-secondary

Change-Id: I53fdd29bc1f0ef132005a93d3cf1cdcd7f2fc05f
2018-11-06 11:43:03 -08:00
Tom Cherry
1eb04561c1 fs_mgr: enable DT fstab based on its status node appropriately
Follow the typical device tree guidelines that a node is only enabled
if it does not have a 'status' property or if it does have a 'status'
property with a value of 'ok' or 'okay'.

Bug: 117933812
Test: status='disabled' DT fstab is not present when reading fstab
Change-Id: Icb4cbe654757658460aabfdb952d71fb8354e09e
2018-11-06 10:44:51 -08:00
Mark Salyzyn
beb4cb8e43 adb: overlayfs failed to remount /system
Regression introduced commit bb1efbd1c6

By not first checking if overlayfs mount on /system is in /proc/mounts
remount fails to discover the override and take the selected action.

Test: adb-remount-test.sh
Bug: 109821005
Change-Id: I1f0bae22caae1bca84fc1e33b508b54d98f4ed5c
2018-11-06 09:49:10 -08:00
David Anderson
f89b1df1a5 init: Regenerate uevents for dependent super partition devices.
This patch adds another uevent-regeneration pass to the first stage
mount. When the super partition spans multiple block devices, we need
/dev/block/by-name symlinks to have been created before we begin mapping
dynamic partitions.

Bug: 116802789
Test: retrofit device boots
Change-Id: I00bb277e1d81385a457c5b4205a95d8fbe365bb2
2018-11-05 17:53:49 -08:00
David Anderson
7632f0c286 liblp: Fix flashing metadata to multiple block devices.
Although metadata is only stored on the first block device, we ideally
want to validate all the block devices before flashing. This patch does
that and in the process converts ValidateAndSerializeMetadata to use
IPartitionOpener.

Bug: 116802789
Test: manual test
      liblp_test gtest

Change-Id: I3f24cfc6f5607309dc3cded0423326c5ba293d26
2018-11-05 19:57:47 +00:00
Justin Yun
ad55005b19 Check sepolicy context for mounting vendor overlay
The vendor overlay source directory must have the same sepolicy
context with the target vendor directory.
Otherwise, the vendor overlay will fail to mount.

Bug: 112955896
Test: Check if a source directory that has a differnt context fails
      to mount on vendor directory.
Change-Id: I2522a8ddc96d4d9b0f34d25a081d20d1ac2dd27a
2018-11-05 17:57:41 +00:00
David Anderson
f27803c435 Merge "fs_mgr: Allow overriding the super partition name via the kernel commandline." 2018-11-03 03:15:32 +00:00
David Anderson
0bfa1c8b3c fs_mgr: Allow overriding the super partition name via the kernel commandline.
For retrofit devices where the super partition is not called "super",
this allows the correct partition to be passed via the kernel
command-line, i.e.:

  androidboot.super_partition=system

Since retrofitting is only supported for A/B devices, we assume that
a partition named this way must be slot-suffixed.

Bug: 116802789
Test: manual test
Change-Id: I930dbbd397d5552e9ded89baa5a7bb0e63c67426
2018-11-02 14:51:16 -07:00
Mark Salyzyn
2fde1ec836 fs_mgr: overlay backing, force filesystem for f2fs
Under the condition of an existing, but broken, filesystem on the
scratch device, force recreation. Add the -f flag for f2fs,
already present for ext4.

Test is enhanced.  The test needs to check, and if necessary wipe
out any existing overrides and reboot before running the remainder
of test.  Report which overrides are being used, and how they are
setup.  Fail if they are not as expected.  Improve efficiency of
checks by reducing the duplication of commands issued to the device.

Test: adb-remount-test.sh
Bug: 109821005
Change-Id: I9ac4fac952e334c00b089fec0b73b2cd2cc0af5c
2018-11-02 13:41:07 -07:00
Justin Yun
818ff63f09 Make fs_mgr_access() available to user build
fs_mgr_access() is used by a public function that is avaliable to
user build.

Test: build fs_mgr for user variant.
Change-Id: I1ec977fa1920add7db3023b181a9a7666b0890b5
2018-11-01 17:25:39 +09:00
Justin Yun
6bab0a9c23 Mount vendor overlay from the system partition
Using overlayfs, the system partition may provide files for older
version of vendor partitions by overlaying on the vendor partition.
Directories in /system/vendor_overlay will be overlaid on the
directories in /vendor to override existing files or provide new
files.

This feature works only if the kernel support overlayfs and has a
patch for override_creds. Otherwise, no-op.

Bug: 114679254
Test: Build and boot: nothing affected without overlayfs, or
                      vendor file is overrided with overlayfs

Change-Id: Iff3a308945299034123ba7bcb40dc787e102730e
2018-11-01 10:26:12 +09:00
Mark Salyzyn
a762e007c5 fs_mgr: overlayfs takes const std::vector<const fstab_rec*>&
fs_mgr_overlayfs_mount_all() and fs_mgr_overlayfs_required_devices()
to also take const std::vector<const fstab_rec*>& argument.

Bug: 117933812
Test: manual adb-remount-test.sh
Change-Id: Ic72fcca1fe32c311ff3f903c7275e6f7dfba46a7
2018-10-31 14:42:44 +00:00
Tom Cherry
8dcae262d7 fs_mgr: fix userdebug/user argument type mismatch
Test: build
Change-Id: I394bd14ef987d3b763869e05fdbf1ed32153ce59
2018-10-29 17:08:23 -07:00
Treehugger Robot
b7d9b6a995 Merge "fs_mgr: fs_mgr_has_shared_blocks() needs logical blk_device" 2018-10-29 22:18:37 +00:00
David Anderson
2cda71c9f6 Merge "liblp: Allow the super partition to span multiple block devices." 2018-10-29 20:57:06 +00:00
Eric Biggers
82c6ba74e2 Merge "init: use libfscrypt for file-based encryption setup" 2018-10-29 17:19:39 +00:00
Mark Salyzyn
1b066c313b fs_mgr: fs_mgr_has_shared_blocks() needs logical blk_device
For logical partitions, the fstab supplied during
fs_mgr_overlayfs_setup() does not have the correct blk_device and
thus check in fs_mgr_has_shared_blocks() inside
fs_mgr_overlayfs_enabled() will fail to provide the correct status.

Call fs_mgr_update_logical_partition() to fix this up.  Side effect
is an API change where fstab can no longer be considered const when
passed into fs_mgr_overlayfs_mount_all() and
fs_mgr_overlayfs_required_devices().

Some additional minor cleanup as well.  Move fs_mgr_rm_all() higher
up as-is in the file as it has no dependencies, which will complicate
future changes.  Add --help to adb-remount-test.sh unit test script,
improve error handling and checking.

Test: adb-remount-test.sh
Bug: 109821005
Bug: 117605276
Change-Id: I548d3797d49661529490d1a0bf96b63e57491704
2018-10-26 22:54:46 +00:00
Mark Salyzyn
044f04baed fastboot: wipe overlayfs for partition
Arrange to delete the overlayfs backing when a specified partition
has been flashed.

Test: manual
Bug: 109821005
Bug: 117605276
Change-Id: I1c6a0341c6cd2ecfbb7c71bec5679a74d579aadd
2018-10-26 20:57:14 +00:00
Eric Biggers
f05da4a4be init: use libfscrypt for file-based encryption setup
The file-based encryption setup code is being refactored into its own
library because it applies to both ext4 and f2fs, not just ext4.  Update
init to use the new location.   For fs_mgr, just remove the include of
ext4_crypt_init_extensions.h since it was unneeded.

Test: built, booted device with f2fs encryption
Change-Id: I392a763e3349f001bdbc09eb9ca975aa3451fd68
2018-10-25 17:10:15 -07:00
Treehugger Robot
89eb017780 Merge "liblp: Add an abstraction layer for opening partitions." 2018-10-25 18:55:47 +00:00
David Anderson
13e160e09f Merge "liblp: Store device information in a new block device table." 2018-10-25 18:54:55 +00:00
Mark Salyzyn
cf81db320e Merge "fs_mgr: fs_mgr_overlayfs_teardown access to dynamic partition data" 2018-10-25 15:08:28 +00:00