From a2cc1ebb722aabbfb246d144e7382211ad3ec789 Mon Sep 17 00:00:00 2001 From: Alistair Delva Date: Wed, 20 May 2020 16:24:00 -0700 Subject: [PATCH] Add ro.boot.fstab_suffix and modify mount_all to use it Currently the ReadDefaultFstab function, which calls GetFstabPath, makes some assumptions about what the fstab will be called and where it is located. This is being used by vold to set up userdata encryption and for gsid, and is even used in the default boot control HAL, so it has become quite baked. The original way for a board to specify things to mount was to use the "mount_all /path/to/fstab" command in init.rc. However, due to the above functionality, the path after mount_all is no longer very useful, as it cannot differ from the inferred path, or userdata encryption and other features will be broken. On Cuttlefish, we have an interest in being able to test alternative userdata configurations (ext4 vs f2fs, encryption on/off, etc.) and currently the only way to achieve this is to either a) modify the ro.hardware or ro.hardware.platform properties, which breaks a bunch of things like default HAL filenames, or regenerate our odm.img or vendor.img filesystems. We can't simply install another fstab and point to it with "mount_all". This change allows the fstab path to be omitted from "mount_all", and adds another property which overrides the existing checks for fstab.${ro.hardware} and fstab.${ro.hardware.platform}. Specifying ${ro.boot.fstab_suffix} will cause fstab.${ro.boot.fstab_suffix} to be checked first. Bug: 142424832 Test: booted cuttlefish with 'mount_all ${ro.hardware} --late' Test: booted cuttlefish with 'mount_all --late' Test: booted cuttlefish with 'mount_all --late' and fstab_suffix=f2fs Test: partially booted cuttlefish with 'mount_all ${ro.hardware}' Test: partially booted cuttlefish with 'mount_all' Change-Id: I3e10f66aecfcd48bdb9ebf1d304b7aae745cbd3c --- fs_mgr/fs_mgr_fstab.cpp | 13 +++---- init/README.md | 5 ++- init/builtins.cpp | 77 ++++++++++++++++++++++------------------- init/check_builtins.cpp | 16 +++++++++ init/check_builtins.h | 2 ++ init/util.cpp | 51 +++++++++++++++++++++++++++ init/util.h | 18 ++++++++++ 7 files changed, 139 insertions(+), 43 deletions(-) diff --git a/fs_mgr/fs_mgr_fstab.cpp b/fs_mgr/fs_mgr_fstab.cpp index 0825a7716..f333a8561 100644 --- a/fs_mgr/fs_mgr_fstab.cpp +++ b/fs_mgr/fs_mgr_fstab.cpp @@ -408,16 +408,17 @@ std::string ReadFstabFromDt() { return fstab_result; } -// Identify path to fstab file. Lookup is based on pattern fstab., -// fstab. in folders /odm/etc, vendor/etc, or /. +// Identify path to fstab file. Lookup is based on pattern +// fstab., fstab., fstab. in +// folders /odm/etc, vendor/etc, or /. std::string GetFstabPath() { - for (const char* prop : {"hardware", "hardware.platform"}) { - std::string hw; + for (const char* prop : {"fstab_suffix", "hardware", "hardware.platform"}) { + std::string suffix; - if (!fs_mgr_get_boot_config(prop, &hw)) continue; + if (!fs_mgr_get_boot_config(prop, &suffix)) continue; for (const char* prefix : {"/odm/etc/fstab.", "/vendor/etc/fstab.", "/fstab."}) { - std::string fstab_path = prefix + hw; + std::string fstab_path = prefix + suffix; if (access(fstab_path.c_str(), F_OK) == 0) { return fstab_path; } diff --git a/init/README.md b/init/README.md index b70366b8f..0dd14900f 100644 --- a/init/README.md +++ b/init/README.md @@ -547,13 +547,16 @@ provides the `aidl_lazy_test_1` interface. * `ref`: use the systemwide DE key * `per_boot_ref`: use the key freshly generated on each boot. -`mount_all [ ]\* [--