Commit graph

879 commits

Author SHA1 Message Date
Treehugger Robot
0730260a6a Merge changes Ib244a98f,Ib173f251
* changes:
  liblp: Don't store BlockDeviceInfo separately in MetadataBuilder.
  liblp: Move backup sectors to the start of the partition.
2018-10-12 20:28:37 +00:00
David Anderson
a520c5e28b liblp: Don't store BlockDeviceInfo separately in MetadataBuilder.
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
2018-10-12 13:05:12 -07:00
David Anderson
06f7a967be liblp: Move backup sectors to the start of the partition.
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
2018-10-12 13:05:11 -07:00
Treehugger Robot
5c61dbd12c Merge "fs_mgr: overlay drop redundant check" 2018-10-12 19:51:11 +00:00
Treehugger Robot
c53a0e9158 Merge "liblp: Add a gtest for sparse image creation." 2018-10-12 15:18:47 +00:00
David Anderson
f89838887f liblp: Add a gtest for sparse image creation.
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
2018-10-11 17:49:50 -07:00
Mark Salyzyn
21afa1693f fs_mgr: overlay drop redundant check
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
2018-10-11 13:45:51 -07:00
Mark Salyzyn
d556c41a48 fs_mgr: deprecate check for ro.build.system_root_image
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
2018-10-10 14:42:29 -07:00
Mark Salyzyn
69ebd440fe fs_mgr: overlayfs create scratch using a Dynamic Logical Partition
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
2018-10-10 12:26:51 -07:00
Mark Salyzyn
b5ca72811c fs_mgr.h cleanup
Drop struct from specifications, fix style.

Test: compile
Change-Id: I94665a41d514501d2f4cd6888361316e08813431
2018-10-10 12:26:49 -07:00
Mark Salyzyn
54e47908c3 fs_mgr: overlayfs deal with verity detection issues
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
2018-10-10 07:26:50 -07:00
Treehugger Robot
a1bb191541 Merge "Handle retry count correctly" 2018-10-10 00:44:49 +00:00
Paul Lawrence
b920cb44aa Handle retry count correctly
Test: vdc startCheckpoint 2 then reboot 3 times checking state

Change-Id: I4eeda7f73d82a7c8b2469571fa558df2fac47354
2018-10-08 14:06:06 -07:00
Mark Salyzyn
be29673f30 fs_mgr: fs_mgr_update_verity_state cleanup
Test: compile
Bug: 109821005
Change-Id: Ia2e7074dd4cfb86619da65a4acb1d06b47154070
2018-10-08 11:38:21 -07:00
Mark Salyzyn
aace48642f fs_mgr: add fs_mgr_access() as no-errno access(,F_OK) wrapper
Simplification of code paths.

Test: compile
Bug: 74595769
Bug: 63736262
Change-Id: Ie03f3895bc4b520fc23854ab662d99497c31bc66
2018-10-05 15:23:53 -07:00
Mark Salyzyn
ea928bbc1f fs_mgr: candidate list check mount_point
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
2018-10-05 15:23:53 -07:00
Chih-Hung Hsieh
747eb149d0 Add noexcept to move constructors and assignment operators.
Bug: 116614593
Test: build with WITH_TIDY=1
Change-Id: I5a7461386946ca623ab509609092aa0ac8418b80
2018-10-05 16:43:47 +00:00
Mark Salyzyn
780db02f7d fs_mgr: split out fs_mgr_overlayfs_setup_dir()
In preparation for adding a list of possible backing storage.

Test: compile
Bug: 109821005
Change-Id: If3664d44c232db32f79b1355799ec239cfe7633a
2018-10-04 15:15:11 -07:00
Mark Salyzyn
e511e3a3b1 fs_mgr: Add fs_mgr_overlayfs_required_devices()
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
2018-10-04 15:15:02 -07:00
Treehugger Robot
02678f32be Merge "Don't hardcode the super partition name." 2018-10-04 19:29:34 +00:00
David Anderson
ba132f1901 Merge "liblp: Remove the guid field from LpMetadataPartition." 2018-10-04 18:20:47 +00:00
Mark Salyzyn
336f759959 fs_mgr: split out fs_mgr_overlayfs_teardown_one()
In preparation for adding a list of possible backing storage.

Test: compile
Bug: 109821005
Change-Id: Id64d3630a646de714831a3c746204440324c206e
2018-10-03 15:10:22 -07:00
David Anderson
e5f2f06b00 liblp: Remove the guid field from LpMetadataPartition.
Bug: 117229984
Test: liblp_test gtest
Change-Id: Ie42b3a8005b1cf711303966a2a117c255f0fb08c
2018-10-03 14:48:42 -07:00
Treehugger Robot
29e9833e39 Merge "fs_mgr/init: use unique_ptr + CLO_EXEC for setmntent()/fopen()" 2018-10-03 21:22:50 +00:00
Treehugger Robot
d7f2c56089 Merge "liblp: Add support for updateable partition groups." 2018-10-03 20:33:45 +00: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
Treehugger Robot
fe0e345ef0 Merge changes from topic "ext4 checkpointing"
* changes:
  make checkpointing work on ext4
  Adding bow dm-target
2018-10-03 20:15:48 +00:00
David Anderson
5246b6c183 liblp: Add support for updateable partition groups.
This patch introduces a new "groups" table in the super partition
metadata. Each entry denotes a named partition group with a maximum
size. All partitions now belong to a group, and the total size of
partitions in a group must not exceed its maximum size. This is enforced
by MetadataBuilder.

There is also a "default" group with no size restriction. This is used
for one-off partitions that aren't restricted by updates, for example,
the scratch partition for overlayfs, or partitions created through
fastbootd.

Bug: 116817738
Test: liblp gtest
Change-Id: I7049ffd35d326e41e25d01b1748cb53a584783a7
2018-10-03 12:14:14 -07:00
Treehugger Robot
cf207d082a Merge "fs_mgr: __mount better detail for ENOENT" 2018-10-03 18:41:40 +00:00
Mark Salyzyn
c4a2534e2d fs_mgr: overlayfs stop adding rootcontext= to mount
By adding the root context, we cause an issue with kernel security
profile, the kernel can kick back overlay mounts because the sepolicy
is not initialized.

observable error when we have root context setup:

SELinux: Unable to set superblock options before the security\
         server is initialized
init: [libfs_mgr]__mount(source=overlay,target=/system,\
         type=overlay,upperdir=/cache/overlay/system/upper)=-1:\
	 Invalid argument

root context was added initially due to paranoia, so the side effects
are non existent unless upperdir sepolicy is adjusted.

Test: manual
Bug: 109821005
Change-Id: Id218add0a32df3b2a4626d8cb8aa783760c78cc4
2018-10-02 14:08:04 -07:00
Mark Salyzyn
22d31c2e68 fs_mgr: overlay: device tree and system as root
fs_mgr_overlayfs_mount_all() should pick up /system even if device tree
does not specify / or /system.

Because of change where we pass fstab to fs_mgr_overlayfs_mount_all(),
/ (or rather /system) overlayfs mount got shifted to early init and
did not occur in first stage init. We need the assumption that /
mount is implied when not specified in the dt fstab to be considered
by overlayfs logic.

Test: manual
Bug: 109821005
Bug: 115751838
Change-Id: Ia8fc5d8e8cc50c66197a91efa80e46d66c2d108d
2018-10-02 14:07:56 -07:00
Paul Lawrence
786d0b27a2 make checkpointing work on ext4
Test: Test script passes

Change-Id: Iafa337947f2fd456aa692ecb112ccc56638f7947
2018-10-02 10:12:33 -07:00
Paul Lawrence
8a9c294f37 Adding bow dm-target
Test: Can load with dm-ctl
Change-Id: I0c6a750340fa6babcfa0f72b66c18a0b3eacd9d8
2018-10-02 10:12:30 -07:00
David Anderson
5cbd2e43ee Don't hardcode the super partition name.
If a device has logical partitions but does not use a partition called
"super", we will need this to be configurable. Note that the "slot"
argument is currently unused, but will be necessary for update_engine if
there are A and B super partitions.

Bug: 116608795
Test: super partition works
Change-Id: Ieb548a158faeb423f3561230f26d582325efbc6b
2018-10-01 14:13:22 -07:00
Mark Salyzyn
03df4238f6 fs_mgr: overlayfs increase logging signal to noise ratio
Remove unnecessary content from logging.  PERROR implies failure,
and logging reports source, so no need to fortify.

Test: compile
Bug: 109821005
Change-Id: Ie25de6ec35dd1890e9a14ecee96956e743a2a91c
2018-09-26 16:08:09 -07:00
Mark Salyzyn
8243f66580 fs_mgr: __mount better detail for ENOENT
By telling us that the target or source is missing for ENOENT, we
can triage whether it is a build/configuration problem or a driver
problem.  Two engineers spend more than a few hours investigating
a build problem rationalizing adding this instrumentation.

Test: compile
Bug: 109821005
Change-Id: I1ecc6230ebee128c0963d6020787230c1e2fb8c1
2018-09-26 16:05:58 -07:00
Mark Salyzyn
5095d89425 liblp: Add MetadataBuilder::UsedSpace()
MetadataBuilder::AllocatableSpace() represents the total space
available.  Adding MetadataBuilder::UsedSpace() to represent the
space used by the existing set of partitions.  This will allow a
caller to predict if a partition can be resized (Grown), or to
create a partition to use up the free space (i.e. scratch).

Test: gTest liblp.UseAllDiskSpace
Bug: 109821005
Change-Id: Iae487d869fe18310c76b48c4281f1d6c1ee333cd
2018-09-25 13:48:14 -07:00
Mark Salyzyn
f35db9b11b fs_mgr: init: adb: add fstab argument to fs_mgr_overlayfs_mount_all
Add an fstab argument for fs_mgr_overlayfs_mount_all so that it can
leverage the locally and timely acquired fstab entries.  Affects all
callers, adb and init.

Test: manual
Bug: 109821005
Bug: 115751838
Change-Id: I96e2045d88525a6ce39bef63327a0fcf0704e9bc
2018-09-25 07:30:55 -07:00
Mark Salyzyn
a526bbea4d fs_mgr: Move fs_mgr_overlayfs_already_mounted higher in file.
Move fs_mgr_overlayfs_already_higher, and switch to const auto& opt.

Test: manual
Bug: 109821005
Change-Id: Iccf05c823ea8946ef87292d8ee355af57d00abdf
2018-09-24 10:21:02 -07:00
Mark Salyzyn
20ff1b2033 liblp: test: fix liblp.UpdateAnyMetadataSlot
Move test to verify we can't read unwritten metadata from
liblp.UpdateAnyMetadataSlot to liblp.CreateFakeDisk.

Test: gTest liblpg_test
Bug: 109821005
Change-Id: I4714c949e2b2d9de6444996a2af2992a821c4a85
2018-09-24 10:20:57 -07:00
Mark Salyzyn
6aaff2fe7d Merge "fs_mgr: overlayfs: const to kNames" 2018-09-21 22:59:19 +00:00
Mark Salyzyn
0006b4de0c Merge "fs_mgr: liblp: add additional debugging details" 2018-09-21 22:58:34 +00:00
Mark Salyzyn
e5ecbb5e50 fs_mgr: overlayfs: const to kNames
Test: compile
Bug: 109821005
Change-Id: I792dc74a7646f4512af201b1451b9f078cea32bf
2018-09-21 13:26:40 -07:00
Mark Salyzyn
a2af0dec14 fs_mgr: liblp: add additional debugging details
Test: none
Bug: 109821005
Change-Id: I759e76f793e8dd6f26f649dc727e80c9955e764f
2018-09-21 13:26:37 -07:00
Daniel Rosenberg
4c93b256f6 fs_mgr: Support checkpoints
Adds support for partitions with checkpointing enabled. If the
checkpoint= fs_mgr flag is set, and the system has checkpointing on,
the partition will be mounted in checkpointing mode.

Test: Use vdc checkpoint commands, the checkpoint=fs fs_mgr flag
      in the fstab, and a kernel containing the f2fs checkpoint
      changes. https://lkml.org/lkml/2018/8/21/22
Change-Id: I3ea8da932de06fcfd2eed06b8640a8b1df837f1f
2018-09-20 17:28:23 -07:00
Treehugger Robot
d812d0dada Merge "fs_mgr: liblp: delete all MetadataBuilder copy and move constructors" 2018-09-07 20:23:34 +00:00
David Anderson
c8ac4e7644 fastbootd: Wait for /dev/block paths when opening logical partitions.
Note that in addition to waiting for the path to appear, we must also
wait for it to be unlinked. Otherwise, we could accidentally access an
older device when opening and closing the same partition twice in a row.

Bug: 114198005
Test: fastboot flashall works
Change-Id: Iddffc34e1ac8aa066c28e7b1a92b09b6dfd7945c
2018-09-06 17:38:06 -07:00
Treehugger Robot
e36f911a92 Merge "libdm: GetDmDevicePathByName log warning" 2018-09-06 21:58:30 +00:00
Mark Salyzyn
fd27e9a56e fs_mgr: liblp: delete all MetadataBuilder copy and move constructors
Test: compile
Bug: 109821005
Change-Id: I21524cba1d183bd53ba89153a45a1483dd315ebf
2018-09-05 14:09:36 -07:00
Mark Salyzyn
9fa35cc170 fs_mgr: liblp: add check failure for sectors_per_block
Test: compile
Bug: 109821005
Change-Id: I88bf4c785c6f46a308c1d8b09edcbde53e29a004
2018-09-05 07:43:35 -07:00