Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9a7d777c authored by Paul Lawrence's avatar Paul Lawrence Committed by Android (Google) Code Review
Browse files

Merge changes I83ca5092,Ib554f5aa into main

* changes:
  Enable flag overlay_dynamic_parititions only
  Don't use heuristics to pick volumes to overlay
parents 3e49def5 f937ee46
Loading
Loading
Loading
Loading
+9 −10
Original line number Diff line number Diff line
@@ -79,16 +79,15 @@ Caveats
  done file by file. Be mindful of wasted space. For example, defining
  **BOARD_IMAGE_PARTITION_RESERVED_SIZE** has a negative impact on the
  right-sizing of images and requires more free dynamic partition space.
- The kernel requires **CONFIG_OVERLAY_FS=y**. If the kernel version is higher
  than 4.4, it requires source to be in line with android-common kernels. 
  The patch series is available on the upstream mailing list and the latest as
  of Sep 5 2019 is https://www.spinics.net/lists/linux-mtd/msg08331.html
  This patch adds an override_creds _mount_ option to OverlayFS that
  permits legacy behavior for systems that do not have overlapping
  sepolicy rules, principals of least privilege, which is how Android behaves.
  For 4.19 and higher a rework of the xattr handling to deal with recursion
  is required. https://patchwork.kernel.org/patch/11117145/ is a start of that
  adjustment.
- The kernel requires **CONFIG_OVERLAY_FS=y**. overlayfs is used 'as is' as of
  android 16, no modifications are required.
- In order for overlayfs to work, overlays are mounted in the overlay_remounter
  domain, defined here: system/sepolicy/private/overlay_remounter.te. This domain
  must have full access to the files on the underlying volumes, add any other file
  and directory types here
- For devices with dynamic partitions, we use a simpler logic to decide which
  partitions to remount, being all logical ones. In case this isn't correct,
  we added the overlay=on and overlay=off mount flags to allow detailed control.
- _adb enable-verity_ frees up OverlayFS and reverts the device to the state
  prior to content updates. The update engine performs a full OTA.
- _adb remount_ overrides are incompatible with OTA resources, so the update
+17 −0
Original line number Diff line number Diff line
@@ -49,6 +49,10 @@
#include "fs_mgr_overlayfs_mount.h"
#include "fs_mgr_priv.h"

// Flag to simplify algorithm for choosing which partitions to overlay to simply overlay
// all dynamic partitions
constexpr bool overlay_dynamic_partitions_only = true;

using namespace std::literals;
using namespace android::fs_mgr;
using namespace android::storage_literals;
@@ -669,6 +673,19 @@ Fstab fs_mgr_overlayfs_candidate_list(const Fstab& fstab) {

    Fstab candidates;
    for (const auto& entry : fstab) {
        // fstab overlay flag overrides all other behavior
        if (entry.fs_mgr_flags.overlay_off) continue;
        if (entry.fs_mgr_flags.overlay_on) {
            candidates.push_back(entry);
            continue;
        }

        // overlay_dynamic_partitions_only simplifies logic to overlay exactly dynamic partitions
        if (overlay_dynamic_partitions_only) {
            if (entry.fs_mgr_flags.logical) candidates.push_back(entry);
            continue;
        }

        // Filter out partitions whose type doesn't match what's mounted.
        // This avoids spammy behavior on devices which can mount different
        // filesystems for each partition.
+2 −0
Original line number Diff line number Diff line
@@ -209,6 +209,8 @@ bool ParseFsMgrFlags(const std::string& flags, FstabEntry* entry) {
        CheckFlag("metadata_csum", ext_meta_csum);
        CheckFlag("fscompress", fs_compress);
        CheckFlag("overlayfs_remove_missing_lowerdir", overlayfs_remove_missing_lowerdir);
        CheckFlag("overlay=on", overlay_on);
        CheckFlag("overlay=off", overlay_off);

#undef CheckFlag

+2 −0
Original line number Diff line number Diff line
@@ -87,6 +87,8 @@ struct FstabEntry {
        bool fs_compress : 1;
        bool overlayfs_remove_missing_lowerdir : 1;
        bool is_zoned : 1;
        bool overlay_on : 1;
        bool overlay_off : 1;
    } fs_mgr_flags = {};

    bool is_encryptable() const { return fs_mgr_flags.crypt; }