Commit graph

132 commits

Author SHA1 Message Date
Martijn Coenen
b3462c123c Fix bug that would prevent us from reserving right amount of space.
Bug: 132403230
Test: inspect dmesg output:
[   10.762678] init: [libfs_mgr]Setting reserved block count on
/dev/block/dm-2 to 32768
[   10.782652] tune2fs: Setting reserved blocks gid to 1065\x0a
[   10.782655] tune2fs: Setting reserved blocks count to 32768\x0a

Change-Id: Id366d478bdd8a748bb1ba97d08a3b52e3cdd1efb
2019-05-10 10:39:54 +02:00
David Anderson
cad2733f49 Don't assume an A/B device when overriding the super partition name.
Bug: 130750333
Test: launch cuttlefish with DAP enabled
Change-Id: I1ea309d448866a8914f58be98d860eca36d47062
Merged-In: I1ea309d448866a8914f58be98d860eca36d47062
2019-04-18 14:35:49 -07:00
Yifan Hong
81f1385589 init: add umount_all builtin.
umount_all is the cleanup step for mount_all.

In particular, the mount_all builtin creates a verity device,
'postinstall-verity', for the following line:

system /postinstall ... ... slotselect_other,logical,avb_keys=...

cppreopt umounts /postinstall but doesn't destroy the postinstall-verity
device, causing OTA to fail (because it cannot destroy the
system_[other] device). umount_all also destroy the verity device.

Note that mount_all does not map system_[other]; it is mapped by
first stage init. Hence, umount_all doesn't destroy it either. The OTA
client is reponsible for unmapping the device itself.

Bug: 129988285
Test: flash, boot, then check `dmctl list devices`, then OTA

Change-Id: Id3ab65b3860b6ea6cfec310ab13652009c81f415
2019-04-15 10:22:57 -07:00
David Anderson
7082f68808 Fix device mapper name clashes on non-A/B devices.
Bug: 123666267
Test: sysfs reports -verity suffix for verity node names
Change-Id: I07fe428ce86209825e39a0ebf7b4d622b93cc81b
2019-03-22 13:47:27 -07:00
David Anderson
ee725f610f init: Support booting off GSIs installed to non-userdata block devices.
Bug: 126230649
Bug: 127953521
Test: GSI boots when installed to sdcard on hikey960
      GSI boots when installed to /data/gsi
Change-Id: Id59926ebe363939c8c5745bb1bf5bd13722dae7e
2019-03-20 18:22:00 -07:00
Mark Salyzyn
60a76f330c fs_mgr: overlay: suppress noise associated with test mounting scratch partition
Add internal fs_mgr_is_ext4 and fs_mgr_is_f2fs to get heads up on
mount failures and thus bypass trying.

Test: adb-remount-test.sh
Bug: 109821005
Change-Id: Ieb1f8c19ced930b6fe2d1791ef710ce528da7e37
2019-03-18 12:50:00 -07:00
Bowgo Tsai
f3e28e1682 libfs_avb: support key rotation for standalone partitions
The FstabEntry.avb_key is renamed to FstabEntry.avb_keys, to
allow specifying multiple avb keys, separated by ':'
(because ',' is already used by fstab parsing).

Bug: 124013032
Test: boot live GSI with multiple allowed AVB keys
Change-Id: Iacd3472a1d5a659dfecf09ea6074d622658f4d0b
2019-02-27 04:13:21 +00:00
Tom Cherry
15800946e0 __android_log_is_debuggable() shouldn't be an apex symbol
Remove a superfluous check in fs_mgr, since those return values are
already impossible for a non-debuggable build.  Replace a one time
call to __android_log_is_debuggable(), since there's no reason to
cache the value or use this symbol.

Test: build
Change-Id: Icd4bef7b616c49d304303747388d7e3018c6fcfc
2019-02-20 12:52:02 -08:00
Tom Cherry
cf80b6d6e5 Refactor fs_mgr_update_verity_state()
fs_mgr_update_verity_state() has two callers with generally different
intentions.  One caller loops through all entries in the default fstab
to set partition.<mount_point>.verified properties.  The other caller
is only interested in whether or a specific mount point has verity
enabled.

Given this, we refactor fs_mgr_update_verity_state() to
fs_mgr_get_verity_mount_point() which takes a single FstabEntry and
returns the mount point used for the dm-verity device or an empty
option if verity is not enabled on that mount point.

Test: adb-remount-test.sh test on blueline
Change-Id: Ic7dd8390509e95b2931b21e544c919a544138864
2019-02-11 12:50:22 -08:00
Tom Cherry
685c2c7b1e Remove old C fs_mgr interface
Remove superfluous fs_mgr flags as well.

Bug: 62292478
Test: tree hugger, fs_mgr_unit_test
Change-Id: Ib307400941b46ca8bcb51d479668efd82fc3ed2d
2019-02-04 15:09:02 -08:00
Treehugger Robot
0ed7819d6a Merge "Restrict zram_writeback permission" 2019-02-02 03:31:38 +00:00
Wei Wang
aa25756426 Restrict zram_writeback permission
Bug: 74582279
Bug: 122659265
Test: Build
Change-Id: Iba610929bc02d7ee5a590f8ec5b440269dbc12f5
2019-02-01 11:57:00 -08:00
Tom Cherry
a3530e6366 Add android::fs_mgr namespace for new Fstab code
Should have been done a while ago, but better late than never.

Test: treehugger
Change-Id: I0ea6e8d459cd3f3b3ce2d00a7a6a9786d52c52dd
2019-01-30 20:20:05 -08:00
Treehugger Robot
6c44d00d79 Merge "fs_mgr: make changes needed to port vold to new Fstab interface" 2019-01-30 06:31:50 +00:00
Tom Cherry
2e545f8b2f fs_mgr: make changes needed to port vold to new Fstab interface
Particularly, capitulate that GetEntryForMountPoint() would be cleaner
than std::find_if() and update the rest of system/core to use it.

Test: build

Change-Id: I982b5a8552d44852d3ab22c20db83afcd4dd652b
2019-01-29 14:56:49 -08:00
Bowgo Tsai
defe1cb5e7 libfs_avb: support enable verity for a standalone partition
The following static function has been added into class AvbHandle to
support loading the AVB hashtree descriptor to enable dm-verity for
a FstabEntry.

  static AvbHashtreeResult SetUpStandaloneAvbHashtree(FstabEntry* fstab_entry);

Bug: 112103720
Bug: 117960205
Test: atest libfs_avb_test
Test: atest libfs_avb_internal_test
Test: Add /system/etc/system_other.avbpubkey, then add
      avb_key=/system/etc/system_other.avbpubkey into /system/etc/fstab.postinstall.
      factory reset, boot a device and checks that system_other is
      mounted with verity (see the serial log below)

Serial log:
-----------
init: [libfs_avb]Built verity table: '1 /dev/block/by-name/system_a
    /dev/block/by-name/system_a 4096 4096 8521
    8521 sha1 895ba03023a35172b393429fadad9ee228b39203
    3405d16fec2cd12ad9e6b36d3bc983e1e83b5e09 10 use_fec_from_device
    /dev/block/by-name/system_a fec_roots 2 fec_blocks 8589 fec_start 8589
    restart_on_corruption ignore_zero_blocks'

init: [libfs_mgr]superblock s_max_mnt_count:65535,/dev/block/dm-7

init: [libfs_mgr]__mount(source=/dev/block/dm-7,target=/postinstall,type=ext4)=0:
Success

Change-Id: Ie339a43ff9c6a7d170e12ef466df666b98ddec19
2019-01-29 22:42:24 +08:00
Tom Cherry
b688d917cd Remove the rest of users of the old style fstab
And deprecate one more old style function that is not used after this
change.

Test: boot, disable and enable verity
Change-Id: Id509f479850120352b4ea4dc3b6c40f6e8e2e53e
2019-01-28 12:34:33 -08:00
Leo Liou
0b721d3dd9 fs_mgr: set ext4 fsverity feature bit
It supports a new feature "fsverity" for ext4 file-system. When someone
adds a mount option "fsverity" to fstab file, fsmgr will use tune2fs to
enable fsverity feature if kernel support.

Bug: 117437571
Test: bootable for phone projects
Change-Id: Icf35715a2f71c430468daaafcde497f8cfe9a18d
2019-01-22 12:22:13 +08:00
Jaegeuk Kim
2fdbdfddac Merge "zram: support zram_writeback" 2019-01-17 21:03:15 +00:00
Treehugger Robot
ccb06c7b2b Merge "Retry mounts on -EAGAIN" 2019-01-17 04:10:19 +00:00
Daniel Rosenberg
5620c6ce0c Retry mounts on -EAGAIN
F2fs may return -EAGAIN on mounting with checkpoint=disable. This
signals that the required garbage collection was taking a while, and
that more garbage collection is required, and will be resumed by
attempting to mount again.

Test: Start device with checkpointing set up with an f2fs userdata
      partition that is in need of heavy garbage collection.
      Mount should fail with EAGAIN and retry
Bug: 122917966

Change-Id: I83341f68e5cffa5f1bd569dfb2037ad5d3cbd7a3
2019-01-16 17:24:50 -08:00
Jaegeuk Kim
2aedc82f02 zram: support zram_writeback
This patch supports zram_writeback enabled by fstab in two ways.

e.g.,
/dev/block/zram0 none swap defaults
    zramsize=1073741824,max_comp_streams=8,zram_loopback_path=/data/unencrypted/zram_swap

==> loopback size is 512MB by default.

Or,
/dev/block/zram0 none swap defaults
    zramsize=1073741824,max_comp_streams=8,zram_loopback_path=/data/unencrypted/zram_swap,zram_loopback_size=1G

==> loopback size can be specified by "zram_loopback_size=%s" with "GB" or "MB".

Or,
/dev/block/zram0 none swap defaults
    zramsize=1073741824,max_comp_streams=8,zram_backing_dev_path=/dev/block/partition

Bug: 74582279
Bug: 122659265
Change-Id: I66a2e6953b4743a34cf732dd0f5b5256c901f247
Signed-off-by: Jaegeuk Kim <jaegeuk@google.com>
2019-01-15 16:07:59 +00:00
David Anderson
42c32bf9af init: Allow first-stage mounts in the second stage if they're formattable.
If /metadata is wiped, but is specified as a first-stage mount, it'll
fail to mount and then skipped as a mount in the second stage. Rather
than add a new flag, this patch piggy-backs on "formattable" since
otherwise there is no way the file system will be formatted.

Bug: 121209697
Test: flashall -w && reboot
Change-Id: If36a12251f398a99b9423713a8bfbe8c33523b66
2019-01-14 17:36:02 -08:00
Yifan Hong
ccdba57545 fs_mgr: overlayfs clears readonly on scratch devices
Fixes adb-remount-test and flashstation because the scratch device
was set to readonly before.

Test: adb-remount-test

Change-Id: I12551d1ed99fb7cfd04f84fcc2b77d3cb94275b2
Fixes: 122454600
Fixes: 122602260
2019-01-10 10:49:05 -08:00
Yifan Hong
0cd2d5f048 fs_mgr_do_mount_one: allow overriding mount_point
Test: boots
Bug: 118634720
Change-Id: Ie2d05fdead27bfb1c922749272ff648bc7c418d1
2018-12-19 10:23:50 -08: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
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
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
Tom Cherry
e1e71b9b98 Merge "init: allow first stage mount to read an fstab" 2018-12-05 20:32:08 +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
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
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
7a66be1a54 fs_mgr fix flags/fs_mgr_flags mismatch
Mount flags prefixed with MS_ are intended for the 'flags' entry of
fstab_rec, not fs_mgr_flags.

Coincidentally, this probably has always worked since this maps to the
'wait' flag, which is almost always set for system in the first place.

Test: build
Change-Id: Id4862bc087aa98e1f0e17145dc3ed74b5d867596
2018-11-30 16:17:17 -08:00
Jaegeuk Kim
5d14b982fa check_fs: skip check_fs if there is no matched EXT4|F2FS_SUPER_MAGIC
We don't need to call fsck, if magic is not matched at all.

Bug: 111895882
Change-Id: Ie728b02ff2fc7d4a20fc011f66643583ea708f9d
Signed-off-by: Jaegeuk Kim <jaegeuk@google.com>
2018-11-30 21:29:15 +00:00
Tom Cherry
9d24734b5c Merge "fs_mgr: fixup 'size' attributes of fstab." 2018-11-30 16:33:54 +00:00
Tom Cherry
fafbb648e0 fs_mgr: fixup 'size' attributes of fstab.
'off64_t' is the correct way to specify a size of a file system, so we
update the various fs_mgr fstab attributes accordingly.

Test: boot
Change-Id: I07ebe687b7c215a8d07ce49d6d32e81b798d1cd3
2018-11-29 13:32:35 -08:00
Bowgo Tsai
c1bc2813c9 fs_mgr: move AVB related source into libfs_avb
This CL also adds namespace android::fs_mgr and remove FsManager* prefix
for class names. Note that android::fs_mgr::FsManagerAvbOps will be removed
in later CLs when fs_mgr doesn't rely on libavb->avb_slot_verify() to
parse vbmeta structs.

Some lingering sources for by_name_symlink_map_ are also removed.

Bug: 112103720
Test: boot crosshatch_mainline-userdebug
Change-Id: I2d1a5cc39bcd5a699da8d5539f191d8c7737c4af
2018-11-29 22:21:33 +08:00
Alistair Strachan
0685af0fd7 Allow non-A/B, non-retrofit devices to override super_partition
Some devices we want to test on, like cuttlefish, may not have a
partition table on any block device Android can see. The partitions are
simply exposed as separate block devices. This means we need to be able
to override the super_partition name to a regular block device name even
on non-A/B devices.

Bug: 113175337
Test: boot test on cuttlefish
Change-Id: I6ff460d0ba7b1e26cb5d60ba446737aa49549c18
2018-11-28 19:05:58 +00: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
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
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
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
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