android_system_core/fs_mgr/include
David Anderson 0aabcbc973 remount: Remove errno interaction from fs_mgr_overlayfs_teardown.
This patch eliminates errno as part of the return contract for
fs_mgr_overlayfs_teardown().

The non-standard use of implicit errno makes it extremely difficult to
reason about how these functions can fail. As it turns out,
fs_mgr_overlayfs_teardown has been consistently failing for a long time,
but in a place where errno isn't set, which meant "enable-verity" never
saw the failure.

The failure was originating from umount2(MNT_DETACH) which guaranteed
that DeleteBackingImage would fail with EBUSY, and DeleteBackingImage is
a binder call that doesn't set errno.

This patch switches to umount() and returns a "busy" status if the
unmount fails with EBUSY. In this case it will also disable the scratch
partition. There is a long-standing existing bug where, for non-VAB
devices, it will delete the underlying scratch partition off super. This
is pretty risky with MNT_DETACH, but that path is left unchanged here.

Some duplicated code in set-verity-state was refactored as well, since
the return value of fs_mgr_overlayfs_teardown is now more complex.

Bug: 241179247
Test: adb-remount-test.sh
Change-Id: I2ca75332b75a302622ba9b86d122a6f2accdda3e
2022-09-19 22:30:05 -07:00
..
fs_mgr snapuserd: Allow connecting to the first-stage daemon. 2021-07-27 19:35:29 -07:00
fs_mgr.h fs_mgr: remove FDE-specific FS_MGR_MNTALL codes 2021-11-09 22:44:50 -08:00
fs_mgr_dm_linear.h fs_mgr: CreateDmTable takes CreateLogicalPartitionParams 2019-09-11 18:32:57 -07:00
fs_mgr_overlayfs.h remount: Remove errno interaction from fs_mgr_overlayfs_teardown. 2022-09-19 22:30:05 -07:00
fs_mgr_vendor_overlay.h Mount vendor overlay from the system partition 2018-11-01 10:26:12 +09:00