Commit Graph

1033 Commits

Author SHA1 Message Date
Treehugger Robot 567c45e10e Merge "Fix sign-compare warnings" 2018-12-17 00:51:13 +00:00
Yi Kong e93040c618 Fix sign-compare warnings
system/core/fs_mgr/fs_mgr_fstab.cpp:161:18: error: comparison of integers of different signs: 'int' and 'const uint64_t' (aka 'const unsigned long') [-Werror,-Wsign-compare]
        if (flag == j->flag) {
            ~~~~ ^  ~~~~~~~

system/core/fs_mgr/fs_mgr.cpp:674:11: error: comparison of integers of different signs: 'int' and 'std::__1::vector<FstabEntry, std::__1::allocator<FstabEntry> >::size_type' (aka 'unsigned long') [-Werror,-Wsign-compare]
    if (i < fstab.size()) --i;
        ~ ^ ~~~~~~~~~~~~

Test: m checkbuild
Change-Id: I056add222a92f99134a49ac141bd143ddd54179b
2018-12-14 16:02:38 -08:00
Treehugger Robot 010a85afe5 Merge "fs_mgr: overlayfs: test w/o sepolicy in enforced mode" 2018-12-14 22:27:17 +00:00
Bowgo Tsai 4c80edf9cd fstab: allow mounting other slot
Adding a new fs_mgr flag 'slotselect_other' to mount _b when _a is
active, or vice versa.

Bug: 113182233
Bug: 112103720
Test: `mount_all fstab.test` with one line using `slotselect_other`.

Change-Id: I96c63141df7722dc30ca9817b0b154e493b9eef9
2018-12-14 05:50:21 +00:00
Treehugger Robot 42c9e7e393 Merge "fs_mgr: overlayfs: test inAdb and inFastboot" 2018-12-14 04:12:12 +00: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
Tom Cherry 6bbe9477f3 fs_mgr: allow boot_devices to be supplies on the kernel commandline
boot_devices in device tree is our last remaining device tree entry
for specifying the kernel commandline.  Since this doesn't make sense
to be included in the fstab, especially as there is no way to
differentiate between different boot devices within a single device
tree as some devices do, it is moved to the kernel commandline.

Bug: 117933812
Test: boot blueline without boot_devices in DT
Change-Id: If498836ae2ef14e68ff761338ef352c20c4a7b3d
2018-12-13 11:13:28 -08:00
Tom Cherry 41216e591b Merge "Allow specifying vbmeta/parts via fstab" 2018-12-13 18:24:34 +00:00
Treehugger Robot 8f3ed62422 Merge changes Ic9957cb3,If7ae257c
* changes:
  fs_mgr: adb-remount-test in non overlayfs world
  fs_mgr: errno handling in fs_mgr_overlayfs_setup()
2018-12-13 15:32:14 +00: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 d202c55453 fs_mgr: errno handling in fs_mgr_overlayfs_setup()
Do not report errno if ENOENT or ENXIO as it is expected when verity
is in fact disabled or not setup on platform.

Reading the default fstab can also result in ENOENT if fstab or dt
are missing on purpose, but if we get an fstab then restore the
errno as we move on.

fs_mgr_has_shared_blocks sets errno, when all we care about is yes
or no answer (EPERM notwithstanding, which indicates do not know).

If no candidates are found to override, and not caused by EPERM,
then suppress errno.

Test: adb-remount-test.sh
Bug: 109821005
Change-Id: If7ae257cb6b738a64ba43d32805760cc292b2fae
2018-12-12 14:21:10 -08:00
Tom Cherry de545a4bb3 Allow specifying vbmeta/parts via fstab
We want to move all information required for first stage mount into
the first stage ramdisk instead of using device tree.  A previous
change allowed reading the fstab from the first stage ramdisk, but
'vbmeta/parts' was still in device tree.  This change allows
specifying the required vbmeta/parts information in the fstab.

The new syntax is that instead of simply specifying 'avb' as an fs_mgr
option, a partition may specify 'avb=<vbmeta partition name>' and that
vbmeta partition will also be initialized by first stage init before
attempting to mount any devices.

Bug: 117933812
Test: boot crosshatch without device tree fstab
Change-Id: Ida1a6da988c10d364b3ccdaa6c5d63e5264d1b27
2018-12-12 13:58:44 -08:00
Tom Cherry 898b642d8a fs_mgr: remove -Wno-unused-variable from cflags
Don't know why this was ever specified, but seems reasonable to remove
it now that we're so close.

Test: build
Change-Id: Ia8d056cd1c9660b3c22531317098ace78e661d6a
2018-12-12 10:30:10 -08:00
Treehugger Robot fe3becb56b Merge "Fix performance-for-range-copy warnings" 2018-12-12 17:46:46 +00:00
Tom Cherry 07eea062d5 Merge "Start using new C++ Fstab class widely" 2018-12-12 17:42:45 +00:00
Tom Cherry 23319ebebf Start using new C++ Fstab class widely
Bug: 62292478
Test: boot
Test: adb-remount-test.sh

Change-Id: Id4715af4c1f03e2cfc67de92d3ea58e933685e51
2018-12-12 17:08:09 +00:00
Greg Kaiser eefd2e9006 fs_mgr_fstab: Add Adiantum support
Adiantum is a crypto method Android is supporting for devices
which don't have AES CPU instructions.  See the paper
"Adiantum: length-preserving encryption for entry-level processors"
(https://eprint.iacr.org/2018/720.pdf) for more details.

We add Adiantum to our list of supported encryption modes.

Bug: 112010205
Test: Tested on a device
Change-Id: I14a400164803a1e217d378ad9bd8b67a61b8b7d0
2018-12-11 15:39:09 -08:00
Chih-Hung Hsieh 1b7b7979af Fix performance-for-range-copy warnings
Bug: 30413223
Test: make with WITH_TIDY=1 DEFAULT_GLOBAL_TIDY_CHECKS=-*,performance*
Change-Id: I3ad102f2b0f971266d57488a3bd57d312f7ee3e6
2018-12-11 10:51:13 -08:00
David Anderson 0059bc76c3 Merge "liblp: Reclaim wasted space from unaligned partitions." 2018-12-11 00:35:42 +00:00
David Anderson dccfdca1e1 liblp: Reclaim wasted space from unaligned partitions.
When allocating a partition with a size that is unaligned (to the
optimal alignment), the remaining sectors are wasted since they are
never reallocated. This is because the free list is guaranteed to only
contain optimally-aligned regions. Unfortunately this means when a
partition is resized, we are wasting a small amount of space each time.
On a non-A/B device, this could wind up being significant.

For example, with an alignment of 512KiB, a 4KiB partition at offset 0
will waste 508KiB of space. The next extent to be allocated by any
partition will start at the next 512KiB.

To address this, we round up extents to the optimal alignment. This
means partitions may wind up slightly over-allocated, versus before,
where they would waste space by making it unavailable.

Bug: 120434950
Test: liblp_test gtest
Change-Id: I555209b301058555526cc4309f7049ae81cf877d
2018-12-10 12:53:52 -08:00
Tom Cherry 298fd6d956 fs_mgr: fix typo
Bug: 62292478
Test: boot
Change-Id: I6bbb6190cb92dcd7f71c16494ea2f2b4871b8b0f
2018-12-10 10:58:38 -08:00
Tom Cherry 1fcf7f7d1f Merge "fs_mgr: use std::string in more places" 2018-12-10 17:34:23 +00:00
Tom Cherry 02eff5cccd Update fs_mgr_update_verity_state() for new C++ Fstab
Bug: 62292478
Test: boot and check verity state
Change-Id: I4912a16ada9a6d72480d7ac905654b764c5d18b6
2018-12-07 14:14:54 -08:00
Tom Cherry c3e7bd3b32 fs_mgr: use std::string in more places
This will ease the transition in the future to using an Fstab struct
that uses std::string instead of char*.

Bug: 62292478
Test: boot

Change-Id: I170db74c2eb6dc16bd21fe65d7e7c685ce5c8b11
2018-12-07 12:35:46 -08:00
Mark Salyzyn 215d1d510e Merge changes I368d3a56,Idb769991,Ia158b6ed
* changes:
  fs_mgr: overlay: use alternate for backing storage
  fs_mgr: overlay: split out fs_mgr_overlayfs_create_scratch()
  fs_mgr: overlay: split out fs_mgr_overlayfs_make_scratch()
2018-12-06 15:26:47 +00:00
Treehugger Robot 323ca1ea6b Merge "fs_mgr: Add fs_mgr_overlayfs_is_setup()" 2018-12-06 01:01:06 +00: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 13a6605070 fs_mgr: overlay: split out fs_mgr_overlayfs_create_scratch()
Reduce some complexity in fs_mgr_overlayfs_setup_scratch()

Test: adb-remount-test.sh
Bug: 119885423
Change-Id: Idb769991f6342739c75654b1d42ab8f8633cbadf
2018-12-05 13:59:33 -08:00
Mark Salyzyn d14eb57377 fs_mgr: overlay: split out fs_mgr_overlayfs_make_scratch()
Reduce some complexity in fs_mgr_overlayfs_setup_scratch()

Test: adb-remount-test.sh
Bug: 119885423
Change-Id: Ia158b6ed140a017fc2f5afb838482e0f8cba1222
2018-12-05 13:59:23 -08:00
Tom Cherry e1e71b9b98 Merge "init: allow first stage mount to read an fstab" 2018-12-05 20:32:08 +00:00
Tom Cherry 5ae47e10c8 Merge "fs_mgr: use more unique_fd" 2018-12-05 00:32:36 +00:00
Alistair Strachan 5d55580fe1 Merge "Handle renamed "super" device correctly" 2018-12-05 00:06:41 +00:00
David Anderson 5cd7969177 Merge "liblp: Allocate "b" extents in the second half of super." 2018-12-04 21:53:48 +00:00
Tom Cherry 0d2621f2ac fs_mgr: use more unique_fd
Modernize a bit of code in preparation for the rest of the
modernization.  Use more unique_fd and fix a few fd leaks in the
process.

Bug: 62292478
Test: boot
Change-Id: I2a6f1abaa1b9a4e979baea36764b91157c2ed218
2018-12-04 13:25:52 -08:00
Alistair Strachan 1906d5f357 Handle renamed "super" device correctly
In the non-retrofit case, the metadata source partition will be
hardcoded as "super", but such a partition may not exist or may have
been overridden by super_partition=<something>. Make this work reliably
by plumbing the resolved metadata block device through, and using it any
time a partition called "super" is requested.

This also fixes a case in the first_stage_mount code that assumed that
detected a non-A/B, non-retrofit case by assuming the metadata source
partition would be called "super".

Bug: 113175337
Test: boot test on cuttlefish
Change-Id: I8ce1defb902e257eeb7170d697b378eba31faee3
2018-12-04 11:21:34 -08:00
Mark Salyzyn dd748aa41c fs_mgr: Add fs_mgr_overlayfs_is_setup()
Provide a means to determine if overlayfs is currently active with
fs_mgr_overlayfs_is_setup().  Search for current clues in the system
that the overrides are in play.  If /mnt/scratch/ is mounted, that
may be enough of a smoking gun because the resource itself may
interfere with operations.

Related to update_engine calling this function to reject performing
an OTA as its operations are incompatible with the overrides.

Test: adb-remount-test.sh
Bug: 120034852
Change-Id: I641163b1559c1a83fe7d0c336d04c10e9956ad3a
2018-12-04 11:06:47 -08:00
Tom Cherry e68bf85fd6 init: allow first stage mount to read an fstab
Now that we have a first stage ramdisk (or use recovery in its place),
it's possible to place a vendor specific fstab along with first stage
init, removing the need for device tree modifications to have an
fstab.

Bug: 117933812
Test: hikey boots with only an fstab in first stage ramdisk
Test: blueline mainline boots with a disabled DT fstab and an fstab in recovery
Change-Id: I4460b88851557a75ba06ff795cd842e7dfb6da46
2018-12-04 11:06:30 -08:00
Tom Cherry bb72b808f4 Merge "Convert fs_mgr_swapon_all() to use the new Fstab struct" 2018-12-04 18:41:56 +00:00
Treehugger Robot a30cff7f89 Merge "fs_mgr: Change scratch margin to 3 X logical_block_size." 2018-12-04 16:30:25 +00:00
Treehugger Robot a7f54b1592 Merge "C++17 is the default now." 2018-12-04 07:53:24 +00:00
David Anderson 8acb5dc1c5 liblp: Allocate "b" extents in the second half of super.
When allocating "b" partitions on a non-retrofit A/B device, prioritize
regions occuring in the second half of the super partition. To make this
effective, the region covering the midpoint sector is split into two
additional regions.

This will allow OTAs to avoid unecessary fragmentation, since each
slot's partitions will be grouped together, leaving a large chunk of
contiguous space available when the OTA deletes the target slot. Since
updates are not allowed to consume more than half of the super
partition, this should guarantee one extent per partition. Note that, if
this restriction is not in place (for example, a developer flashes a
massive "system_b"), then an additional extent will be allocated due to
the region that was split.

Bug: 120433288
Test: liblp_test gtest
Change-Id: I1797e59e14c8b0d4d0e6855a1d984e8159b21df2
2018-12-03 16:58:34 -08:00
Tom Cherry 0c7fb42949 Merge "fs_mgr: Create a C++ Fstab struct" 2018-12-04 00:10:33 +00:00
Mark Salyzyn 756eebe819 fs_mgr: Change scratch margin to 3 X logical_block_size.
Found a device with a 3/4MB erase block, give a wider margin so that
flashing a single partition is unlikely to be blocked by scratch.

Add documentation to tell developers to flashall to clear scratch.

Test: adb-remount-test.sh
Bug: 109821005
Change-Id: Ic219283f4c42e457b98991bcd1752253e182eff3
2018-12-03 12:15:25 -08:00
Treehugger Robot 307337fb40 Merge changes I6a4c3d9b,Ia5cdb797,I946eb605,Ieff3f6ea
* changes:
  init: overlay: allow fs_mgr_overlayfs_required_devices to report partitions
  fastboot: call fs_mgr_overlayfs_teardown() in UpdateSuper
  fs_mgr: overlay: disable overrides in recovery or fastbootd.
  fs_mgr: overlay: umount scratch more aggressively
2018-12-03 20:14:02 +00:00
Treehugger Robot 5d595da516 Merge "fs_mgr fix flags/fs_mgr_flags mismatch" 2018-12-03 19:07:45 +00:00
Tom Cherry 3055457a96 Convert fs_mgr_swapon_all() to use the new Fstab struct
Bug: 62292478
Test: build
Change-Id: Ifbde514bf73d3ce2f321326291daa025b6afac46
2018-12-03 09:41:01 -08:00
Tom Cherry d0be7a5277 fs_mgr: Create a C++ Fstab struct
Create a C++ Fstab struct with the intention to eventually deprecate
the legacy C 'fstab' struct.  This also contains functions for
converting between the two fstab variants to ease in the transition.

Bug: 62292478
Test: boot

Change-Id: I6fb51c6a99e65192708792719df01960cf6b432a
2018-12-03 09:40:55 -08:00
Elliott Hughes 3c59cb8420 C++17 is the default now.
Test: builds
Change-Id: I6814455e9ad2cdcf99ad66de38a3ad0bfb440d80
2018-12-03 09:02:18 -08:00
Mark Salyzyn 9040aa5665 fs_mgr: overlay: disable overrides in recovery or fastbootd.
Disable overrides if we are booting up in recovery or fastbootd.
Check for existence of /system/bin/recovery.

Test: adb-remount-test.sh
Bug: 120034852
Change-Id: I946eb605300226d31356ecac209d6367f4e13526
2018-12-03 07:33:38 -08:00