Commit graph

809 commits

Author SHA1 Message Date
Tao Bao
d262346b57 Merge "fs_mgr: Drop some unneeded dependencies." 2018-08-15 18:14:16 +00:00
Tom Cherry
066fcdf820 Include some warnings about vendor_available for fsmgr.
The interface to fsmgr is subpar and while we haven't had time to
revisit it, we absolutely do not want to expose this to vendors in a
way that would force us to keep this interface in the future.

Test: n/a
Change-Id: I970048aa2e45d7f7eca357d052141e90d6e01123
2018-08-14 13:11:14 -07:00
Mark Salyzyn
7186787342 fs_mgr: correct error handling
Fix a few areas that mismanage error return values, and can result in
confusing messaging from the adb commands.

Test: manual
Bug: 109821005
Change-Id: Ib00069c9605df453ac8f600c7906649deebfd626
2018-08-14 07:56:03 -07:00
Mark Salyzyn
5f6b06973b fs_mgr: use ro.persistent_properties.ready
Replace more complicated logic that determines that persistent
properties are now valid with a simple check of
ro.persistent_properties.ready.

Test: manual
Bug: 109821005
Change-Id: I3e43df8283cb97abbf5c0333e64db4ad11703798
2018-08-14 07:55:55 -07:00
Tao Bao
7aa4608053 fs_mgr: Drop some unneeded dependencies.
libfs_mgr doesn't have direct dependencies on libfec_rs / libkeyutils /
libsquashfs_utils. They were only needed when libfec and libext4_utils
were statically linked into libfs_mgr.

Bug: 112494634
Test: `m -j installclean && m -j bootimage` with aosp_taimen-userdebug.
      Check the installed files in recovery image.
Test: `mmma -j system/core/fs_mgr`
Change-Id: I4b12c2df344fabba4942b6db943cf43a031b591d
2018-08-13 23:03:03 -07:00
Greg Kaiser
b4bf8c66a3 fs_mgr: Small fix in overlayfs setup/teardown
In user builds, we fix fs_mgr_overlayfs_{setup,teardown} to
properly set the optional 'change' boolean, if it was provided.

Test: TreeHugger
Change-Id: I91fc99d801f8fd782b21f0ecaecddfc7744f0c3e
2018-08-10 05:24:25 -07:00
Mark Salyzyn
d9e6c2020e fs_mgr: get fs_mgr_mount_all to call fs_mgr_overlayfs_mount_all
After fs_mgr_mount_all has added the resources, let
fs_mgr_overlayfs_mount_all to read-only mount overlayfs over the
possible system partitions.

Test: compile
Bug: 109821005
Bug: 110985612
Change-Id: I7101a04c57de1a26283b1523636d07fa8e19ffc7
2018-08-08 15:38:53 -07:00
Mark Salyzyn
b28389f5ee fs_mgr: add overlayfs handling for squashfs system filesystems
Logistics for adb remount on developer builds for readonly system
partitions using overlayfs to deal with not being able to remount
with read-write.

Conditions are that filesystem is squashfs, read-only, debug build,
kernel supports overlayfs.  The default is a valid /cache/overlay/
directory, with .../<mount_point>/upper and .../<mount_point>/work,
associated with each system partition <mount_point>.

Will take the sepolicy of context of lowerdir as rootcontext= option.

Add fs_mgr_overlayfs_mount_all() to recurse through
fs_mgr_read_fstab_default(), and checking against /proc/mounts to
add any acceptable overlayfs mounts.  The checking with /proc/mounts
makes sure we do not overlayfs overtop an overlayfs.

Add fs_mgr_overlayfs_setup(const char*, const char* bool*) and
fs_mgr_overlayfs_teardown(const char*, bool*) to respectively setup
or teardown the overlayfs support directories.  Return value
includes success and optional supplied change booleans.

Test: compile
Bug: 109821005
Bug: 110985612
Change-Id: Ie9b4e9ca0f2bdd9275ac2e2e905431636948e131
2018-08-08 15:38:53 -07:00
Greg Kaiser
954c141c48 Revert "Support Speck encryption."
This reverts commit 49c27c5cb2.

Remove the Speck encryption support. It was eventually
decided not to allow Speck in Android P, so this code
is no longer needed and wasn't used outside of testing.

Bug: 112009351
Test: Confirmed AES continues to work with FBE.
Change-Id: Ia5458143be5687fff8d541d8fa2c8ee24a369da4
2018-08-07 10:10:31 -07:00
Xin Li
5d707816ac Merge "Merge Android Pie into master" 2018-08-07 16:51:24 +00:00
Treehugger Robot
4f878cf6cb Merge "fs_mgr: Do not mount empty partitions." 2018-08-07 00:52:34 +00:00
David Anderson
6868cb9f5e fs_mgr: Do not mount empty partitions.
If a logical partition is resized to 0 bytes, it will have no extents.
This is not allowed by device-mapper, but is useful for effectively
compacting partitions with "fastboot flashall". If all logical
partitions are resized to 0, then resized to their intended size, then
we will allocate extents more efficiently.

However, if a partition is left with a zero size (either intentionally
or not), this should not throw the device into a reboot loop due to
CreateLogicalPartitions failing. Instead we skip partitions with no
extents.

Bug: 78793464
Test: with fastbootd:
        fastboot create-partition example 4096
        fastboot resize-partition example 0
      device reboots successfully

Change-Id: I572efa949176c8c3c493ef00438d8badd4d7cf4f
2018-08-06 15:59:38 -07:00
David Anderson
4d71d85805 liblp: Allow flashing to readonly logical partitions.
By default, logical partitions with the readonly flag are created with a
readonly device. This change allows callers of CreateLogicalPartition
to create writable devices so they can still be flashed.

Bug: 78793464
Test: fastboot flash product_services works with fastbootd
Change-Id: Ia8d2761a3067e3b62815acbf0b6fb7f033072ba2
2018-08-06 15:47:26 -07:00
David Anderson
8660f5a85c Merge "liblp: Try to merge extents during partition resizes."
am: b0c9318493

Change-Id: Ib124843c47f710665e1d9134eae11edb7575863e
2018-08-03 15:58:35 -07:00
David Anderson
727c80765d Merge "liblp: Add more logging for logical partition operations."
am: 805bc5d757

Change-Id: If08681fc946f0bd21854459c7efd5986e81a7823
2018-08-03 15:57:21 -07:00
Treehugger Robot
b0c9318493 Merge "liblp: Try to merge extents during partition resizes." 2018-08-03 20:02:41 +00:00
David Anderson
1aab3909f7 liblp: Try to merge extents during partition resizes.
When adding extents to partitions, if the previous extent and new extent
are contiguous, merge them together to avoid allocating unnecessary
device-mapper targets.

Bug: 79173901
Test: liblp_test gtest
Change-Id: I80087df9aea8141c5e16f8d4cdb3dd7da02aee8c
2018-08-03 11:02:25 -07:00
David Anderson
b9f734c936 liblp: Add more logging for logical partition operations.
This logs when partition tables update, when partitions resize, and when
partitions are unmapped from device mapper.

Bug: N/A
Test: N/A
Change-Id: I1125332c79fccc3ebc556b3b48856901e2503c47
2018-08-03 10:59:43 -07:00
David Anderson
0bade5b848 Merge changes from topic "liblp-blocksize"
am: d0e5bcc13f

Change-Id: I95e14110705740db955800fc05ff9b1371226cc1
2018-08-02 12:31:15 -07:00
David Anderson
4d9c7459c4 liblp: Require block-aligned partition sizes.
DM_TABLE_LOAD will reject dm-linear entries if their size is not a
multiple of the backing device's logical block size. For example, a
partition of 10GiB+512 bytes will fail to map in device-mapper if the
logical block size is 4096 bytes. To address this, this patch adds a
few changes to liblp:

The block size given to lpmake is now recorded in LpGeometryMetadata.
The block size must be a multiple of the sector size. In addition,
partiton sizes are now aligned to the block size, and the super
partition must have enough free space to allocate at least one block (in
addition to storing metadata).

GrowPartition now has multiple checks that the block-size invariant is not
violated, to ensure that no invalid partition tables will be created.

Bug: 79173901
Test: liblp_test gtest
Change-Id: I484aac1f9b90ebd92dc1c89ce1e09cd89bbb441e
2018-08-02 10:33:41 -07:00
David Anderson
de1daa72aa liblp: Simplify GrowPartition().
The partition resize algorithm duplicates a lot of logic because it
handles the final free interval separately from other free intervals.
This is unnecessary and makes it harder to change the actual algorithm.

This change makes GrowPartition() treat the final free space region the
same as free gaps in between partitions. It does this by converting the
extent list into a gap list, and then adds a final gap for the remainder
of the free space. The resize function no longer has to treat the end of
the disk separately.

This patch does not change the way partitions are allocated, it is
purely a refactoring.

Bug: 79173901
Test: liblp_test gtest
Change-Id: I4780f20b23fe021eac62de874b061857712c04fe
2018-08-02 09:14:47 -07:00
David Anderson
432a51dcdc Merge "liblp: Add a ResizePartition helper to MetadataBuilder."
am: ddcee93c01

Change-Id: I187c1aba212a754d282f3ec7a65f3fda549f6e28
2018-08-02 09:13:02 -07:00
Treehugger Robot
ddcee93c01 Merge "liblp: Add a ResizePartition helper to MetadataBuilder." 2018-08-02 16:01:24 +00:00
David Anderson
2e755e38af liblp: Add a ResizePartition helper to MetadataBuilder.
This change is to assist with implementing the fastbootd "resize-partition"
command. The GrowPartition and ShrinkPartition functions are now
private.

Bug: 78793464
Test: N/A
Change-Id: Ic66a3052359e2558663272ff6e014704206b197e
2018-08-01 17:41:29 -07:00
Luis Hector Chavez
d4ee791365 Merge "fs_mgr: Always mount tmpfs with MS_NOEXEC"
am: 8f2a34a89b

Change-Id: I80ac903329f24756ef8a3d9bade11f446b2e1c31
2018-08-01 16:16:27 -07:00
Treehugger Robot
8f2a34a89b Merge "fs_mgr: Always mount tmpfs with MS_NOEXEC" 2018-08-01 22:41:56 +00:00
Tom Cherry
780d80b5a6 Merge "init: run fsck for early mount partitions"
am: 6e05552e35

Change-Id: I6b44584616557ef3c58039eff6ce7eaf3c2d7623
2018-08-01 14:11:19 -07:00
Tom Cherry
6e05552e35 Merge "init: run fsck for early mount partitions" 2018-08-01 21:02:35 +00:00
Tom Cherry
81ae07509d init: run fsck for early mount partitions
Bug: 111883560
Test: fsck runs successfully during early mount
Change-Id: I19bcd2610f87f5331f94c228fcbec8f9379fc5e8
2018-07-31 13:58:17 -07:00
David Anderson
4444219482 Merge "liblp: Allow building liblp as a shared library."
am: 2756339c77

Change-Id: I20ea48eff3843461cdc00c470643088d350195f6
2018-07-28 15:57:51 -07:00
David Anderson
f792e4163d liblp: Allow building liblp as a shared library.
Bug: 79173901
Test: system image, partition_tools both build
Change-Id: I70f45d4cebfbddc39d03aa3fb3a56b6c48a20d7e
2018-07-27 19:34:56 -07:00
Jerry Zhang
3051d54902 Merge "Move recovery to /system/bin"
am: 0937a84521

Change-Id: Ic3f3eb82178e6c5af22945e3aaaac3f86beb4ec8
2018-07-27 13:34:11 -07:00
Treehugger Robot
0937a84521 Merge "Move recovery to /system/bin" 2018-07-27 20:25:53 +00:00
Tao Bao
ff2886ae61 Merge "fs_mgr: Build and use shared libs."
am: 9ff0669ac1

Change-Id: I4ee5e75801722174e9e9dac4edc833872cda45af
2018-07-25 21:58:34 -07:00
Tao Bao
9ff0669ac1 Merge "fs_mgr: Build and use shared libs." 2018-07-26 04:48:46 +00:00
Sandeep Patil
6d79d9f303 Merge changes Ica6bf5c6,I3f626433
am: 56f76ec018

Change-Id: I5f98902dafea961c892ace0145fbcf923b6838cb
2018-07-25 19:38:10 -07:00
Treehugger Robot
56f76ec018 Merge changes Ica6bf5c6,I3f626433
* changes:
  fs_mgr: libdm: add support android-verity target.
  dmctl: Do not skip argument if not matched with '-ro'.
2018-07-26 02:29:12 +00:00
Tao Bao
a9fad6cd15 fs_mgr: Build and use shared libs.
Bug: 78793464
Test: `m dist`
Change-Id: I21ed5de72217c5cfa37e0217b0e79ed0a6f82031
2018-07-25 13:42:39 -07:00
Jerry Zhang
5de2be5cd5 Move recovery to /system/bin
Executables should be in /system/bin
rather than sbin. Change lookup paths
in a few places to reflect this.

Test: recovery is in system/bin
Bug: 78793464
Change-Id: Ibcdff7abf1f21e2566e02cad8bdb3c26ee500534
2018-07-24 21:42:23 -07:00
Sandeep Patil
efc5479085 fs_mgr: libdm: add support android-verity target.
The support for android-verity makes it possible for us to test
raw verified filesystem images to be attached to android-verity
target and have it verified by the kernel.

This makes the testing of android-verity device mapper target
much easier as it doesn't _have_ to be used for root mount.

Bug: 72722987
Test:
 $ losetup /dev/block/loop0 /data/local/tmp/verity_fs.img
 $ dmctl create verity-fs android-verity 0 4200 \
   Android:7e4333f9bba00adfe0ede979e28ed1920492b40f 7:0

Change-Id: Ica6bf5c6e1fd758fdb4005fc8a09755f369a8a0f
Signed-off-by: Sandeep Patil <sspatil@google.com>
2018-07-23 15:24:55 -07:00
Sandeep Patil
0d469de9a0 dmctl: Do not skip argument if not matched with '-ro'.
'dmctl create' command would fail if '-ro' flag is not
used. This happend because the argument in place of '-ro'
is skipped unconditionally.

Bug: 72722987
Test:
 $ losetup /dev/block/loop0 fs.img
 $ dmctl create FOO linear 0 25600 /dev/block/loop0 0

Change-Id: I3f6264336b9c9a1b5de76f3a1d29e6045453f9cb
Signed-off-by: Sandeep Patil <sspatil@google.com>
2018-07-23 14:50:26 -07:00
David Anderson
af5064d47c Merge "fs_mgr: Add a method for creating one-off partition instances."
am: 67c5ca20e2

Change-Id: I5ce89869e60d29fc67bfb29c6e3bde9a1e9f7dd4
2018-07-23 13:40:11 -07:00
David Anderson
23de22d54b fs_mgr: Add a method for creating one-off partition instances.
fastbootd needs to temporarily map and unmap logical partitions in order
to flash them. To make this easier, this change introduces fs_mgr
methods to create and destroy a single logical partition by name.

Bug: 79173901
Test: N/A
Change-Id: Ic085f2175c26a5edf5f18544012dcfe6d8088f09
2018-07-23 11:43:27 -07:00
Hridya Valsaraju
22c2202e75 Revert "Use more shared libraries in adb and init."
This reverts commit fbd79687e6.

Reason for revert: b/111734137

Change-Id: I70e23ed20d16821a555b448d4ac76fe9e130afa5
2018-07-23 17:48:57 +00:00
Jerry Zhang
fbd79687e6 Use more shared libraries in adb and init.
fs_mgr is used by several different
processes in both system and recovery,
so it makes sense for it to be a shared
library to save space.

libadbd is used by adbd, recovery (as minadbd)
and fastbootd so it should be shared as well.

Bug: 78793464
Test: compiles
Change-Id: I4225f4d1a44e6e5811c68a55595d1f94f0773114
Merged-In: I4225f4d1a44e6e5811c68a55595d1f94f0773114
(cherry picked from commit aacfc68acf)
2018-07-20 17:54:44 +00:00
David Anderson
37716f6c81 Merge "fs_mgr: Remove early prototype code."
am: 881be58f41

Change-Id: I4215c6e183ddbda94cbb0de77f271a68fe21640b
2018-07-19 16:39:56 -07:00
David Anderson
e0384bbc69 fs_mgr: Remove early prototype code.
This early code is no longer needed now that logical partitions can be
created and flashed normally.

Bug: 79173901
Test: N/A
Change-Id: I393ef23b3d3ce1cd9c80833358051838d0e9f333
2018-07-19 14:38:33 -07:00
David Anderson
3d6c541347 Merge "liblp: Allow packing partition data into super images."
am: 17fde657bc

Change-Id: I25d1ac542adadd35ea92721d03234acd6e1cd78f
2018-07-19 12:17:42 -07:00
David Anderson
9555f3dcf6 liblp: Allow packing partition data into super images.
This change allows partition data to be included in the sparse image for
the super partition. The data is specified as a map from partition name
to partition image file. The image file can either be a normal file or a
sparse image. If it is sparse, it is unpacked into a temporary file and
then re-packed into the super image.

Bug: 79173901
Test: (1) lpmake -S with a partition image flashes to walleye.
      (2) The image can be mounted if it contains a filesystem.
      (3) simg2img will successfully unpack the image.

Change-Id: I98e9af3bfec9863143c1b95a1712b1d435942542
2018-07-18 16:53:42 -07:00
David Anderson
3271911d03 Merge "liblp: Allow specifying a custom block size when building sparse images."
am: 54f40303d5

Change-Id: I7f981d8d0625c9fafd192827b75f89d46bd38464
2018-07-18 14:12:41 -07:00