Commit graph

23 commits

Author SHA1 Message Date
Mark Salyzyn
7d6431d852 fs_mgr: overlayfs: test fix problems with runtime apex bind mounts
bind mounts create administrivia in /proc/mounts that can not be
easily discerned to confirm expectations.  We squash the stutter,
and filter out overlay backing references for /system/<path>/<file>.

Test: adb-remount-test.sh
Bug: 122737045
Change-Id: I61342f5f76f54a1a8201a52efb8054acde100a6f
2019-01-15 11:42:03 -08:00
Justin Yun
d3e2a78a99 Exclude mount entries for vendor overlay
When testing adb-remount with overlayfs, vendor overlay may fail the
test because there are unexpected overlayfs uses by vendor overlay.
By excluding mount entries for vendor overlay, the test runs
regardless of vendor overlay mount.

Bug: 122231184
Test: run adb-remount-test.sh with vendor overlay mount
Change-Id: I795774b27d5e5f973792337813b67487a5d72e29
2019-01-10 00:40:33 +00:00
Bowgo Tsai
fa416f9bec Support host build for libdm and libfstab
The host builds for both libs are needed for libfs_avb host unit test.
Also replaces strlcat()/strlcpy() with snprintf() because the former
doesn't have a glibc version. Or switch char* to std::string*.

Bug: 112103720
Bug: 117960205
Test: m libdm ARCH=x86_64
Test: m libfstab ARCH=x86_64
Test: atest libdm_test
Test: atest fs_mgr_unit_test
Test: boot a device

Change-Id: Id9b92b5286b8ed9ab0d80f18ab5802dcfeb83dfa
2019-01-08 17:56:56 +08:00
Mark Salyzyn
b3c0074917 fs_mgr: overlayfs test fix adb_sh
Some commands like 'adb_sh grep " rw," /proc/mounts' do not preserve
the embedded spaces when transferred to the device and thus do not
entirely behave as expected.  There are several commands issued this
way throughout the test that are similarly broken.  To add
consistency, pass any arguments that are not explicitly (double)
quoted and contain embedded spaces as quoted to preserve.

Also devices that report the kernel internal device /dev/root in
/proc/mounts should be suppressed when investigating whether
overlayfs is needed.  If /dev/root is reported, then we should assume
that the mount point / represents it for the following df command
when trying to determine if the partition is right-sized.

When there is only one device attached, and a serial number is not
specified, correctly determine this condition to progress to
the testing.

Test: adb_remount_test.sh
Bug: 122231184
Change-Id: I913e297dd272d6691110bb5d7a7c7f54321b6833
2019-01-07 21:39:56 +00:00
Mark Salyzyn
38a17f0d76 fs_mgr: overlayfs: test issues with single super device
Cleanup test issues with single super device.  Indicate mount point
instead of partitions as that can lead to confusion when referencing
the partition when there is none.  For example root (/) partition
uses overlay on /system.  Resolve a script syntax error when there
are no devices.  Fix script logic surrounding detection of overlayfs
takeover and handling of reboot device request from
adb disable-verity.

In README.overlayfs.md discuss
BOARD_<partitiion>IMAGE_PARTITION_RESERVED_SIZE and its negative
impact on right sizing.

Soften README.overlayfs.md wording with respect to update_engine
to match changes in handling.

Test: adb-remount-test.sh
Bug: 120536582
Bug: 109821005
Change-Id: Iad7e19a436322ff9c3bdc597f4545028be112ff5
2018-12-17 11:26:03 -08:00
Mark Salyzyn
436464ab71 fs_mgr: overlayfs: test w/o sepolicy in enforced mode
Skip sepolicy test if device is not in enforcing mode.

Test: adb-remount-test.sh
Change-Id: I1558674819bda0c9f575d5202f693fec55c9d84f
2018-12-13 16:48:41 -08:00
Mark Salyzyn
f7572ec8ff fs_mgr: overlayfs: test inAdb and inFastboot
If no serial number is supplied, then check if there is 0 devices

Test: adb-remount-test.sh
Change-Id: Ie78c379078d3d99d67594a5be1a22795bfcc6d36
2018-12-13 16:19:35 -08:00
Mark Salyzyn
da27fa0b53 fs_mgr: adb-remount-test in non overlayfs world
Extend test script to check non overlayfs case too.  Establish
whether overlayfs is supported, or needed, and adjust expectations.
For the flash vendor code, make sure it is the _right_ vendor,
skip instead of fail.

Improve quality of the testing and handle more cases.

Test: adb-remount-test.sh
Bug: 109821005
Change-Id: Ic9957cb378d8e7737ffc4ba04078c1cb6bbd1bbd
2018-12-12 14:21:42 -08:00
Mark Salyzyn
f269312466 fs_mgr: overlay: use alternate for backing storage
When we have multiple physical super partitions, it is prudent to
take the alternate super physical partition in its raw entirety
rather than to construct a logical partition out of the current
super partition's limited remaining space.

SideEffect: alternate boot partitions destroyed for the sake of debug
Test: adb-remount-test.sh (including manually disabled to check
      both code paths).
Bug: 119885423
Change-Id: I368d3a5619f69de3b0d1fcad73c4b42d25d0d969
2018-12-05 14:01:59 -08:00
Mark Salyzyn
03d6f9a176 fs_mgr: overlay: test assumption wrong if verity is enabled
Test script assumes overlayfs takeup after disable-verity, although
that can happen if verity is already disabled, it is not the case
for devices that just had it disabled.  Move takeup and first stage
init tests downwards to where the condition is guaranteed.

Differentiate the test for devices that support or have verity, and
those that do not.

Fortify test to also use /data mount to check init first stage limit.

Test: adb-remount-test.sh
Bug: 109821005
Change-Id: I5241d6c97bf374614e50aa0aa18a1b9d118be093
2018-11-30 07:49:32 -08:00
Mark Salyzyn
a30b6964d6 fastboot: propagate error for format command
If fastboot format command fails, return error.

Test: adb-remount-test.sh
Bug: 109821005
Change-Id: Ic4e1a1dea8861028f19ac7f9c834d26e8adba56c
2018-11-27 13:51:42 -08:00
Mark Salyzyn
cb2f6b6776 fs_mgr: overlayfs: resize scratch should it be too small
If scratch gets made too small (eg: fastboot flash scratch small-file)
it can not recover without a workaround.  The workaround is not
intuitive, (adb enable-verity then adb disable-verity to erase and
re-establish the proper sized scratch.  This needs to be automatic.
If we detect it is too small to support a filesystem, resize it to an
more appropriate size if it exists.

Alter unit test to check for fastboot characteristics and assumptions
associated with the scratch partition, and a test case to flash the
partition.

Test: adb-remount-test.sh
Bug: 109821005
Change-Id: Icfceaa461c2bf13ca5a7dd4e34675dde8a4d251f
2018-11-27 13:46:55 -08: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
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
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
Treehugger Robot
b7d9b6a995 Merge "fs_mgr: fs_mgr_has_shared_blocks() needs logical blk_device" 2018-10-29 22:18:37 +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
Mark Salyzyn
0b23968e25 fs_mgr: overlayfs unit test
Provide a means to test out overlayfs work

Test: adb-remount-test.sh
Bug: 109821105
Bug: 117605276
Change-Id: Ia6114c8f4d0c3424cb869d002cc61cfc6863151c
2018-10-22 12:36:10 -07:00
Tom Cherry
f274e78eeb fs_mgr/init: use unique_ptr + CLO_EXEC for setmntent()/fopen()
We ran into an issue with an fd leaking due to missing both CLO_EXEC
and fclose() in related code, so let's make sure we're safe here too.

Test: boot
Change-Id: Ief893c936859815c78fa6d7e06cb88ad34aadbac
2018-10-03 13:19:04 -07:00
Mark Salyzyn
eba4706a2e fs_mgr: Add support in fs_mgr_read_fstab_file for /proc/mounts
Generate fstab from /proc/mounts.  Basically like any regular fstab
minus the requirement for the Android fs_mgr_flags.  Added a unit
test to confirm that fs_mgr_read_fstab("/proc/mounts") matches the
setmntent("/proc/mounts")+getmntent() content.

As a result, discovered a bug in parse_flags that would report "ro"
if the "rootcontext=..." flag was referenced.

Test: fs_mgr_unit_test
Bug: 109821005
Change-Id: I635ee979e11ee089b09adbedb5f42b6ba78026de
2018-06-27 14:49:06 -07:00
Mark Salyzyn
596fac3c6d fs_mgr: fs_mgr_get_boot_config_from_kernel_cmdline deal with quote
Spans quoted with " are dealt with atomically, and are stripped from
the key/value results when parsing the kernel cmdline.

Test: compile, device boot, fs_mgr_unit_test
Bug: 109821005
Change-Id: I45f3d7395f34295edefdeaafa4c15c6ee25cc4da
2018-06-08 16:04:17 -07:00