Commit graph

64 commits

Author SHA1 Message Date
David Anderson
c132bf80ae snapuserd: Remove dependence on libfs_mgr.
The only function we use from libfs_mgr is WaitForFile, so factor that
out into libfs_mgr_file_wait. libfs_mgr has too much dependence on AOSP
internals to build on the host.

Bug: 288273605
Test: builds
Change-Id: I8e5eb4075ae01b9ca64074422171a487179e7943
2023-08-03 16:15:34 -07:00
Yi-Yo Chiang
96126069c2 fs_mgr: Split libfs_mgr and libfstab
The goal is to make the header definitions of the two curiously
intertwined libraries less chaotic.

After this change, libfstab's header would be self contained. In the
sense that all symbols exported by its headers are defined in its
compilation units.
libfs_mgr would still embed libfstab like before, it can use internal
symbols (symbols not exported by public headers) of libfstab through
the libfstab/fstab_priv.h private header.

Keep include_fstab/ as a symbolic link pointing to its new location.
This is a temporary workaround as there are still some bad build rules
(incorrectly) depending on the old include path with Android.bp
`include_dirs` directive.

Bug: 293695109
Test: build
Change-Id: Ib70a84984ac2cbfca5f5b27fadebf6a16e58146a
2023-08-01 04:56:41 +00:00
Yi-Yo Chiang
c30f033b4e fs_mgr: Remove include_dirs declaration
We aren't using anything through the removed path.
We also shouldn't use `include_dirs` to begin with, as it bypasses any
build system checks.

Bug: 293695109
Test: build
Change-Id: I06f7450c3ce545aa2583f8c3f8db18c45073f69e
2023-08-01 04:56:41 +00:00
David Anderson
07339000d4 Remove local_include_dirs from fs_mgr_defaults.
fs_mgr_defaults gets used in lots of places, propagate
local_include_dirs to where it's needed so it doesn't cause problems on
modules that don't have an "includes" directory.

Bug: 291083311
Test: builds
Change-Id: Ief2f6362f584b99d3e2dc7dc1b46450609ad189d
2023-07-14 12:30:35 -07:00
David Anderson
f8f3b627ae fs_mgr: Split fs_mgr_overlayfs into two separate files.
One of the paint points for fs_mgr_overlayfs is that mounting and
scratch management code are somewhat unrelated but very intertwined in
the same file.

Split it into two files: fs_mgr_overlayfs_mount, which is only for
mount-related code, and fs_mgr_overlayfs_control, which is only for
setup/teardown code.

The code removed from fs_mgr_overlayfs_control.cpp is code that moved
to fs_mgr_overlayfs_mount.cpp.

This converts a bunch of functions to "static", and splits
fs_mgr_priv_overlayfs.h into two new files (fs_mgr_overlayfs_mount.h and
fs_mgr_overlayfs_control.h).

Bug: N/A
Test: remount
Change-Id: I83da43652b4787f344da75a1d30177df1d7f63b2
2023-07-13 13:01:20 -07:00
Jiakai Zhang
cf16f4d794 Make libfstab available to APEXes.
The ART module needs this library to determine whether to put dexopt
artifacts in dalvik-cache.

Bug: 287958783
Test: m
Change-Id: Idf338702d4f54e9c40c0692ea29e7d83e91aca38
2023-06-23 22:28:49 +01:00
Yi-Yo Chiang
e8d85b5814 remount: Merge 'remount' and 'set-verity-state'
Dedup fs_mgr_remount.cpp and set-verity-state.cpp by merging them
together and make '/system/bin/set-verity-state' a symlink to
'/system/bin/remount'.

Bug: 241688845
Test: adb-remount-test
Change-Id: I42a2344b9bdac112bf8767d428a99cb020267546
2022-11-03 22:58:43 +08:00
Yi-Yo Chiang
ce2dbd009f remount: Remove AVB 1.0 code & opaque exit code
* Remove AVB 1.0 (fec).
* Assert device is bootloader unlocked in main().
* Since error is already logged to stderr and logd, there is no need to
  return an opaque enum value as error code. Just return 1 if main()
  encounters any error.

Bug: 241688845
Test: Presubmit
Test: adb-remount-test
Change-Id: I06df6f92a3d4adaca77061920736056c9051c112
2022-10-06 18:54:19 +08:00
Yi-Yo Chiang
ad06b405ee fs_mgr_overlayfs: Cleanup -user build stubs
* Categorize functions in fs_mgr_overlayfs.h into three classes:
  - Type 1: common and non-critical utilities.
  - Type 2: internal routines for facilitating remount.
  - Type 3: external entry points for users of fs_mgr_overlayfs, like
            fs_mgr_overlayfs_mount_all().
* Move type 1 to common utils header fs_mgr_priv.h & fs_mgr.cpp.
* Move type 2 to new private header fs_mgr_priv_overlayfs.h.
* Keep type 3 in fs_mgr_overlayfs.h.
* Move set-verity-state.cpp under fs_mgr so it can include
  fs_mgr_priv_overlayfs.h. File is reformatted as a result. We should
  eventually merge and dedup set-verity-state and fs_mgr_remount.
* Add myself to OWNERS for remount-related maintenance work.

Bug: 241179247
Bug: 241688845
Test: Full build -user and -userdebug build.
Test: Presubmit
Test: Treehugger run v2/android-gki/adb_remount
Change-Id: Id5fd0e2b12c693939d712a586dd553cc4d8bfeb1
2022-09-26 16:46:03 +08:00
David Anderson
6cdd9bd784 Remove support for AVB 1.0.
Bug: 204598884
Test: treehugger
Change-Id: Ibfb46aa6c2f761dbb3a9b5f0b16336e510417620
2021-11-30 00:57:49 -08:00
Yi-Yo Chiang
6455f27e1b Make clean_scratch_files work
clean_scratch_files.rc seems to never work as intended due to
missing domain transition rules.
Add a 'remount' domain to the platform policies to allow
remount-related operations, including clean_scratch_files.
Merge remount and clean_scratch_files binary to simplify the added
policies.

Bug: 204836146
Test: 1. Use a VAB device, for example bramble-userdebug
  2. adb remount system
  3. adb reboot fastboot && fastboot flash system system.img
  4. recovery (fastbootd) should mark the remount scratch as disabled
  5. fastboot reboot && adb shell mount | grep scratch => nothing
  6. adb logcat | grep 'clean_scratch_files|gsid' => shows that
    disabled image "scratch" is removed during boot
Change-Id: I18d543868d1f37d43b483eae7517b707e46df1bd
2021-11-02 22:10:46 +08:00
Pirama Arumuga Nainar
cdf919d1f0 [fs_mgr] Use shared libutils for remount
Bug: http://b/197965342

remount depends on libbinder.so which already depends on libutils.so.
When linking remount with libutils.a, the linker tries to fetch objects
from libutils.a to redefine undefined symbols in libbinder.so.  This
causes linker failure with upstream LLD.  Switching to shared
libutils.so instead doesn't increase the dependency closure for remount.

Test: build with aosp/1809741 which has lld with the above behavior.
Change-Id: I858042a08babe2c2db1fc8c7eeb5de62dda5f328
2021-08-30 12:18:08 -07:00
Treehugger Robot
0e13b0ebb4 Merge "fs_mgr: Separate the required modules of core and recovery variants" 2021-08-18 05:33:13 +00:00
Bart Van Assche
0223cd89f7 Reduce the queue depth of loop devices used by the zram driver
Make the queue depth of loop devices identical to that of the underlying
storage device. This patch reduces latency by lowering the queue depth.
With this patch applied I see the following:

 # cat /sys/block/loop30/queue/nr_requests
32

Bug: 194450129
Test: Built Android images, installed these and verified that the queue depth of loop devices is 32 instead of 256.
Change-Id: Ifa16084c7df3a54d9559c2388abc4a8392ff88c6
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2021-08-12 15:42:51 -07:00
Yi-Yo Chiang
db819f5a7d fs_mgr: Separate the required modules of core and recovery variants
Bug: 191369319
Test: Presubmit
Test: Verify libfs_mgr.recovery no longer depends on core variation
  modules in the ninja graph.
Change-Id: I3c8b1f3d00ff9a67f4d9ea552052e308e550c403
2021-07-30 22:22:29 +08:00
David Anderson
a07503afc1 Make libfs_mgr and its dependencies vendor_ramdisk_available.
This is needed to link libfs_mgr with snapuserd.

Bug: 193833730
Test: builds
Change-Id: I5abd706fe134fecebb80ecb790b5be0495e2b925
2021-07-23 16:50:06 -07:00
Bowgo Tsai
a8c6b9d27f fs_mgr: License boilerplate
Bug: 191507548
Test: TreeHugger
Change-Id: I2924d1733fc64de69681971ab42a526dc3bbcc1d
2021-07-09 06:24:04 +00:00
Inseob Kim
2e20058069 Completely migrate init first stage to Soong
adb_debug.prop is migrated too. And ramdisk_available is added to all
dependencies.

Bug: 187196593
Test: boot
Change-Id: I59cd149e0021211b8fd59c44b93bbf18dc8637bf
2021-06-18 14:26:55 +09:00
Bob Badour
d69ad69a93 [LSC] Add LOCAL_LICENSE_KINDS to system/core
Added SPDX-license-identifier-Apache-2.0 to:
  bootstat/Android.bp
  cli-test/Android.bp
  code_coverage/Android.bp
  cpio/Android.bp
  debuggerd/crasher/Android.bp
  debuggerd/proto/Android.bp
  diagnose_usb/Android.bp
  fs_mgr/libdm/Android.bp
  fs_mgr/libfiemap/Android.bp
  fs_mgr/liblp/Android.bp
  fs_mgr/libsnapshot/Android.bp
  fs_mgr/libstorage_literals/Android.bp
  fs_mgr/libvbmeta/Android.bp
  fs_mgr/tests/Android.bp
  fs_mgr/tools/Android.bp
  gatekeeperd/Android.bp
  healthd/Android.bp
  healthd/testdata/Android.bp
  init/Android.bp
  init/Android.mk
  init/sysprop/Android.bp
  init/test_kill_services/Android.bp
  init/test_service/Android.bp
  libappfuse/Android.bp
  libasyncio/Android.bp
  libbinderwrapper/Android.bp
  libcrypto_utils/Android.bp
  libcrypto_utils/tests/Android.bp
  libdiskconfig/Android.bp
  libgrallocusage/Android.bp
  libkeyutils/mini_keyctl/Android.bp
  libmodprobe/Android.bp
  libnetutils/Android.bp
  libpackagelistparser/Android.bp
  libprocessgroup/Android.bp
  libprocessgroup/cgrouprc/Android.bp
  libprocessgroup/cgrouprc_format/Android.bp
  libprocessgroup/profiles/Android.bp
  libprocessgroup/setup/Android.bp
  libqtaguid/Android.bp
  libsparse/Android.bp
  libstats/push_compat/Android.bp
  libsuspend/Android.bp
  libsync/Android.bp
  libsystem/Android.bp
  libsysutils/Android.bp
  libusbhost/Android.bp
  libutils/Android.bp
  libvndksupport/Android.bp
  libvndksupport/tests/Android.bp
  llkd/Android.bp
  llkd/tests/Android.bp
  property_service/libpropertyinfoparser/Android.bp
  property_service/libpropertyinfoserializer/Android.bp
  property_service/property_info_checker/Android.bp
  qemu_pipe/Android.bp
  reboot/Android.bp
  rootdir/Android.bp
  rootdir/Android.mk
  rootdir/avb/Android.bp
  rootdir/avb/Android.mk
  run-as/Android.bp
  sdcard/Android.bp
  set-verity-state/Android.bp
  shell_and_utilities/Android.bp
  storaged/Android.bp
  toolbox/Android.bp
  trusty/apploader/Android.bp
  trusty/confirmationui/Android.bp
  trusty/confirmationui/fuzz/Android.bp
  trusty/coverage/Android.bp
  trusty/fuzz/Android.bp
  trusty/fuzz/test/Android.bp
  trusty/gatekeeper/Android.bp
  trusty/gatekeeper/fuzz/Android.bp
  trusty/keymaster/Android.bp
  trusty/keymaster/fuzz/Android.bp
  trusty/libtrusty/Android.bp
  trusty/libtrusty/tipc-test/Android.bp
  trusty/secure_dpu/Android.bp
  trusty/storage/interface/Android.bp
  trusty/storage/lib/Android.bp
  trusty/storage/proxy/Android.bp
  trusty/storage/tests/Android.bp
  trusty/utils/spiproxyd/Android.bp
  trusty/utils/trusty-ut-ctrl/Android.bp
  usbd/Android.bp
  watchdogd/Android.bp

Added SPDX-license-identifier-Apache-2.0 SPDX-license-identifier-BSD to:
  debuggerd/Android.bp
  fastboot/Android.bp
  libkeyutils/Android.bp

Added SPDX-license-identifier-Apache-2.0 SPDX-license-identifier-BSD
    SPDX-license-identifier-MIT
to:
  libcutils/Android.bp

Added SPDX-license-identifier-Apache-2.0 SPDX-license-identifier-MIT
to:
  fs_mgr/Android.bp
  fs_mgr/libfs_avb/Android.bp
  trusty/Android.bp
  trusty/utils/rpmb_dev/Android.bp

Added SPDX-license-identifier-BSD
to:
  fastboot/fuzzy_fastboot/Android.bp

Bug: 68860345
Bug: 151177513
Bug: 151953481

Test: m all

Exempt-From-Owner-Approval: janitorial work
Change-Id: Id740a7d2884556081fdb68876584b25eb95e1bef
2021-02-19 12:59:05 -08:00
Elliott Hughes
c3a206ccda Revert "[LSC] Add LOCAL_LICENSE_KINDS to system/core"
This reverts commit 187b7d1950.

Reason for revert: system/core is multiple projects, not one.

Change-Id: I790ea41741f8cd9b8b6db2f59a49e71fb0958fd6
2021-02-16 20:01:20 +00:00
Bob Badour
187b7d1950 [LSC] Add LOCAL_LICENSE_KINDS to system/core
Added SPDX-license-identifier-Apache-2.0 to:
  bootstat/Android.bp
  cli-test/Android.bp
  code_coverage/Android.bp
  cpio/Android.bp
  debuggerd/crasher/Android.bp
  debuggerd/proto/Android.bp
  diagnose_usb/Android.bp
  fs_mgr/libdm/Android.bp
  fs_mgr/libfiemap/Android.bp
  fs_mgr/liblp/Android.bp
  fs_mgr/libsnapshot/Android.bp
  fs_mgr/libstorage_literals/Android.bp
  fs_mgr/libvbmeta/Android.bp
  fs_mgr/tests/Android.bp
  fs_mgr/tools/Android.bp
  gatekeeperd/Android.bp
  healthd/Android.bp
  healthd/testdata/Android.bp
  init/Android.bp
  init/Android.mk
  init/sysprop/Android.bp
  init/test_kill_services/Android.bp
  init/test_service/Android.bp
  libappfuse/Android.bp
  libasyncio/Android.bp
  libbinderwrapper/Android.bp
  libcrypto_utils/Android.bp
  libcrypto_utils/tests/Android.bp
  libdiskconfig/Android.bp
  libgrallocusage/Android.bp
  libkeyutils/mini_keyctl/Android.bp
  libmodprobe/Android.bp
  libnetutils/Android.bp
  libpackagelistparser/Android.bp
  libprocessgroup/Android.bp
  libprocessgroup/cgrouprc/Android.bp
  libprocessgroup/cgrouprc_format/Android.bp
  libprocessgroup/profiles/Android.bp
  libprocessgroup/setup/Android.bp
  libqtaguid/Android.bp
  libsparse/Android.bp
  libstats/push_compat/Android.bp
  libsuspend/Android.bp
  libsync/Android.bp
  libsystem/Android.bp
  libsysutils/Android.bp
  libusbhost/Android.bp
  libutils/Android.bp
  libvndksupport/Android.bp
  libvndksupport/tests/Android.bp
  llkd/Android.bp
  llkd/tests/Android.bp
  property_service/libpropertyinfoparser/Android.bp
  property_service/libpropertyinfoserializer/Android.bp
  property_service/property_info_checker/Android.bp
  qemu_pipe/Android.bp
  reboot/Android.bp
  rootdir/Android.bp
  rootdir/Android.mk
  rootdir/avb/Android.bp
  rootdir/avb/Android.mk
  run-as/Android.bp
  sdcard/Android.bp
  set-verity-state/Android.bp
  shell_and_utilities/Android.bp
  storaged/Android.bp
  toolbox/Android.bp
  trusty/apploader/Android.bp
  trusty/confirmationui/Android.bp
  trusty/confirmationui/fuzz/Android.bp
  trusty/coverage/Android.bp
  trusty/fuzz/Android.bp
  trusty/fuzz/test/Android.bp
  trusty/gatekeeper/Android.bp
  trusty/gatekeeper/fuzz/Android.bp
  trusty/keymaster/Android.bp
  trusty/keymaster/fuzz/Android.bp
  trusty/libtrusty/Android.bp
  trusty/libtrusty/tipc-test/Android.bp
  trusty/secure_dpu/Android.bp
  trusty/storage/interface/Android.bp
  trusty/storage/lib/Android.bp
  trusty/storage/proxy/Android.bp
  trusty/storage/tests/Android.bp
  trusty/utils/spiproxyd/Android.bp
  trusty/utils/trusty-ut-ctrl/Android.bp
  usbd/Android.bp
  watchdogd/Android.bp

Added SPDX-license-identifier-Apache-2.0 SPDX-license-identifier-BSD to:
  debuggerd/Android.bp
  fastboot/Android.bp
  libkeyutils/Android.bp

Added SPDX-license-identifier-Apache-2.0 SPDX-license-identifier-BSD
    SPDX-license-identifier-MIT
to:
  Android.bp
  libcutils/Android.bp

Added SPDX-license-identifier-Apache-2.0 SPDX-license-identifier-MIT
to:
  fs_mgr/Android.bp
  fs_mgr/libfs_avb/Android.bp
  trusty/utils/rpmb_dev/Android.bp

Added SPDX-license-identifier-BSD
to:
  fastboot/fuzzy_fastboot/Android.bp

Bug: 68860345
Bug: 151177513
Bug: 151953481

Test: m all

Exempt-From-Owner-Approval: janitorial work
Change-Id: I5bd81adb5cdcf2b4dd4141b204eb430ff526af8f
2021-02-16 04:10:03 -08:00
Yo Chiang
d542910553 adb remount -R should enable DSU if suitable
If executing `adb remount -R` and DSU is running but disabled, then
enable the DSU (one-shot mode) so that the reboot afterwards would stay
within the DSU guest system.
Normally reboot within a DSU guest system would bring the device back to
the host system. However when doing adb remount -R, we actually doesn't
want to exit DSU, but wish to reboot back into DSU guest system again
with remount machinery (overlayfs) properly set up.

Also sort the header include order.

Bug: 165925766
Test: Within a DSU guest system, DSU disabled, adb remount -R
  => After reboot, system is DSU and overlayfs is mounted
Test: adb-remount-test.sh within DSU guest system
Change-Id: I72a7a568e985b183d357ae6e1a7d0113e9921200
2021-01-22 22:15:10 +08:00
Hung-ying Tyan
e7cb09d226 Remove SkipMountingPartitions from vendor libfstab
SkipMountingPartitions() should only be called from a system process
as the config file is in /system_ext.
Remove it from the vendor variant of libfstab.

Bug: 158301941
Test: build hardware/interfaces/boot/1.1/default/boot_control and check symbol
Change-Id: I834183a623c0711dd79b89486fc3fc80f9710801
2020-07-03 17:16:21 +08:00
David Anderson
8696a5d11b remount: Do not allow remounting during checkpoints.
Bug: 157540389
Test: manual test
Change-Id: I5931a583e48ddac05f319629ae2f7f5f0f6cf032
2020-06-18 11:51:01 -07:00
Treehugger Robot
405d26dacb Merge "Set e2freefrag and e2fsdroid as required by libfs_mgr_defaults" 2020-02-04 22:57:36 +00:00
David Anderson
c13586faea remount: Use /data for backing scratch storage.
Currently, this is only enabled for Virtual A/B devices. When /data uses
F2FS, then proper pinning support must be enabled.

Because /data cannot be mounted in recovery, we can't delete the scratch
image backed by /data while in fastbootd. Instead, we mark it as
disabled in /metadata. The remount command now has an init script that
checks for and removes a disabled scratch partition.

Bug: 134949511
Test: adb remount on V A/B device with patched F2FS
Change-Id: Ifc8720378259654472d3822e97059b6c366f601d
2020-01-28 12:04:38 -08:00
Alessio Balsini
843820ee13 Set e2freefrag and e2fsdroid as required by libfs_mgr_defaults
libfs_mgr_defaults uses the e2fsdroid binary, make this dependency
explicit.
Add also e2freefrag as a dependency in preparation for filesystem
fragmentation monitoring.

Bug: 146078546
Test: m + e2freefrag on device
Change-Id: I878d1b090809861c803f6b17fbb3813e03842a50
Signed-off-by: Alessio Balsini <balsini@google.com>
2020-01-25 13:11:17 +00:00
David Anderson
43482de3f9 fs_mgr: Move libfiemap into libfs_mgr, and introduce libfs_mgr_binder.
This eliminates libfiemap as a standalone library and instead bundles it
into libfs_mgr. All consumers of libfiemap need libfs_mgr, and having
them tightly coupled reduces linkage complexity.

When to use libfs_mgr: In recovery, first-stage-init, or when libfiemap
or overlayfs is not used.

When to use libfs_mgr_binder: When not in recovery/first-stage init, and
overlayfs or libfiemap is needed. In this case, IImageManager will proxy
over binder to gsid.

Bug: 134949511
Test: builds, fiemap_writer/image_test passes.
Change-Id: I4c1a5698afdbf9b3bf87accec98254c1fb6f4e0e
2019-12-20 16:41:34 -08:00
Paul Crowley
7160fc1139 fs_mgr: Add stable_inodes flag to encrypted ext4
Also put libfscrypt into fs_mgr via whole_static_libs
since it's now a dependency.

Bug: 143307095
Test: we can use the inline policy on it
Change-Id: I82d7d5330abef76ce82accea25d2663748e87a8b
2019-10-30 13:35:48 -07:00
David Anderson
924858cd18 libdm: Improve the reliability of dm device paths.
This fixes a race condition where WaitForFile() after
GetDmDevicePathByName appears to succeed, but a subsequent operation on
the path fails. This can happen when CreateDevice() is called
immediately after a call to DeleteDevice (from any process), and the
path is re-used, enqueuing udev events to remove and re-add the block
device.

The fix for this is to introduce a new variant of CreateDevice() that
has a timeout parameter. When the timeout is positive, CreateDevice()
will wait for a /dev/block/mapper/by-uuid symlink to be created, which
signals that ueventd has finished processing the operation.

ueventd will now create these by-uuid symlinks for device-mapper nodes.
Unfortunately, the uuid is only available during "change" events, so we
have to special case device-mapper symlink creation. And since the uuid
is not available during "remove" events, we simply find matching links
to remove them.

This ensures that callers of CreateDevice() can use the device path
knowing that no asynchronous removals are pending. Code that uses the
old CreateDevice+WaitForFile pattern will be transitioned to the new
method.

Note that it is safe to ignore the timeout, or to use the "unsafe"
CreateDevice, if the caller ensures the path by other means. For example
first-stage init has no device removal, and regenerates uevents until
it has acquired all the paths it needs.

Finally, since libdm now inspects sysfs unconditionally, libdm consumers
need r_dir_file perms for sysfs_dm in their sepolicy. Additionally
linking to libdm now requires linking to libext2_uuid.

Bug: 135771280
Test: libdm_test
      device flashes, boots
Change-Id: If5a7383ea38f32a7fbbcf24842dce6a668050a70
2019-07-11 15:39:52 -07:00
David Anderson
c65121306a Introduce inotify-based replacements for fs_mgr_wait_for_file.
Bug: 134966533
Test: fs_mgr_unit_test gtest
Change-Id: I36802b87cec59b5277267eb919851ca390fea425
2019-06-18 15:27:09 -07:00
Mark Salyzyn
c3fc2aa964 fs_mgr: overlay: resize other OTA partitions to zero to make space
If we do not have at least the minimum space to create a scratch
partition, let's resize the other partitions to zero to make the
space and try again.

Specify additional shared library dependencies for remount command.
margin_size could never be calculated because "scratch" partition
does not exist, so use super partition instead as argument to
GetBlockDeviceInfo.

Add a "Now reboot your device for settings to take effect" message
if the -R argument was not supplied.  Adjust some of the messages
to be clearer.

Manual test: On a full DAP device, resize or flash both a and b side
for system, vendor and product with fastboot to duplicate failure
conditions of limited space and check remount command resizes other
side partitions to mitigate.

Test: manual and adb_remount_test.sh
Bug: 131390072
Change-Id: I34c4a973f88a5e1e06b64af9589a84721dd1bbbd
2019-05-02 13:46:22 -07:00
Mark Salyzyn
4469fb1c06 fs_mgr_remount: support legacy devices (marlin)
Deal with first version of verity for legacy products.

Test: system/core/fs_mgr/tests/adb-remount-test.sh
Bug: 120448575
Bug: 123079041
Change-Id: I7a2dd8309cbb19751fdbb05d4efc30c486615e04
2019-02-27 13:03:13 -08:00
Mark Salyzyn
1188ce4e1d fs_mgr: remount: add -R argument
The -R flag tells remount it can reboot to disable verity or to
run fsck on an ext4 deduped filesystem, or both.

Testing may include a manual component because adb-remount-test.sh
needs to run from a device in an enable-verity state to test this.

Only recognizes chained avb.

Test: adb-remount-test.sh
Bug: 122602260
Change-Id: I6ce4372532d9b933dcca9e2bec544d525b76c4d9
2019-02-27 13:03:13 -08:00
Mark Salyzyn
6b3f587ac7 fs_mgr: add remount command
There is currently no good option for callers to setup overlayfs
on-device, it is automated as part of the adb services.  Add a
remount command that does what is needed that simulates the salient
behaviors of the adb remount command.

Clean up some noise restoring device to original state when done.

Test: adb-remount-test.sh
Bug: 122602260
Change-Id: Idf213800a8182cb1c51600c8f574df8a8cd68d4a
2019-02-27 13:03:13 -08:00
David Anderson
0e330f12bc init: Add support for GSI installations in first-stage mount.
Bug: 121209697
Test: gsi boots
Change-Id: I69db0f8e999da366e46728b1008602f543cd79f6
2019-01-16 17:45:07 -08:00
bohu
91c4bd75c8 disable darwin build for libfstab
It broke mac sdk build

Change-Id: I5435cea7747d36c2ea46ed2e6c1c51bb032c6585
2019-01-11 14:26:56 -08:00
Bowgo Tsai
d79dd84479 libfs_avb: refactoring
This commit has the following changes:

    1. Builds libfs_avb via "fs_mgr/libfs_avb/Android.bp" instead of
       "fs_mgr/Android.bp", and removes the libfs_avb source
       dependencies on "fs_mgr/fs_mgr_priv.h".

    2. Moves static functions in fs_avb.cpp into util.cpp or
       avb_util.cpp, depending on whether the function is related to
       AVB or not.

    3. Introduces two host unit tests: libfs_avb_test and
       libfs_avb_internal_test, the former is to test public
       <fs_avb/fs_avb.h> APIs, while the latter is to test libfs_avb
       internal functions.

    4. Splits fs_avb_unittest_util.* into:
       - fs_avb_test_util.* (host static lib: libfs_avb_test_util),
       - basic_test.cpp (host executable: libfs_avb_test)

Bug: 112103720
Bug: 117960205
Test: atest libfs_avb_test
Test: atest libfs_avb_internal_test
Test: boot a device
Change-Id: I11d6c9e9019e20b594d9321b9a28118d4806e5a7
2019-01-10 18:11:48 +08: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
Yifan Hong
bf80e7dd91 Move parts of roots.cpp from librecovery
Move some mounting functionalities from librecovery so that
other modules can also mount logical partitions correctly.

- Also, refactor to use C++ Fstab struct.
- Also, fixed CreateLogicalPartitions() to take full path of
super device.

Test: run recovery tests
Test: vintf_object_recovery_test

Bug: 118634720
Bug: 113182233
Bug: 62292478
Change-Id: Ie02c3a941ed801fdae5818099faf5f3863444296
2018-12-19 10:23:50 -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
Elliott Hughes
3c59cb8420 C++17 is the default now.
Test: builds
Change-Id: I6814455e9ad2cdcf99ad66de38a3ad0bfb440d80
2018-12-03 09:02:18 -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
Justin Yun
6bab0a9c23 Mount vendor overlay from the system partition
Using overlayfs, the system partition may provide files for older
version of vendor partitions by overlaying on the vendor partition.
Directories in /system/vendor_overlay will be overlaid on the
directories in /vendor to override existing files or provide new
files.

This feature works only if the kernel support overlayfs and has a
patch for override_creds. Otherwise, no-op.

Bug: 114679254
Test: Build and boot: nothing affected without overlayfs, or
                      vendor file is overrided with overlayfs

Change-Id: Iff3a308945299034123ba7bcb40dc787e102730e
2018-11-01 10:26:12 +09:00
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
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
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
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
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