Merge "Skip system/bin/bootstrap/linkerconfig"
diff --git a/debuggerd/crash_dump.cpp b/debuggerd/crash_dump.cpp
index e3ea455..2a769c7 100644
--- a/debuggerd/crash_dump.cpp
+++ b/debuggerd/crash_dump.cpp
@@ -23,7 +23,6 @@
 #include <sys/types.h>
 #include <sys/un.h>
 #include <sys/wait.h>
-#include <syscall.h>
 #include <unistd.h>
 
 #include <limits>
diff --git a/fs_mgr/fs_mgr_fstab.cpp b/fs_mgr/fs_mgr_fstab.cpp
index 7189a71..36bd75d 100644
--- a/fs_mgr/fs_mgr_fstab.cpp
+++ b/fs_mgr/fs_mgr_fstab.cpp
@@ -488,13 +488,21 @@
     return boot_devices;
 }
 
-template <typename Pred>
-std::vector<FstabEntry*> GetEntriesByPred(Fstab* fstab, const Pred& pred) {
+// Helper class that maps Fstab* -> FstabEntry; const Fstab* -> const FstabEntry.
+template <typename FstabPtr>
+struct FstabPtrEntry {
+    using is_const_fstab = std::is_const<std::remove_pointer_t<FstabPtr>>;
+    using type = std::conditional_t<is_const_fstab::value, const FstabEntry, FstabEntry>;
+};
+
+template <typename FstabPtr, typename FstabPtrEntryType = typename FstabPtrEntry<FstabPtr>::type,
+          typename Pred>
+std::vector<FstabPtrEntryType*> GetEntriesByPred(FstabPtr fstab, const Pred& pred) {
     if (fstab == nullptr) {
         return {};
     }
-    std::vector<FstabEntry*> entries;
-    for (auto&& entry : *fstab) {
+    std::vector<FstabPtrEntryType*> entries;
+    for (FstabPtrEntryType& entry : *fstab) {
         if (pred(entry)) {
             entries.push_back(&entry);
         }
@@ -835,25 +843,27 @@
     return !fstab->empty();
 }
 
-FstabEntry* GetEntryForMountPoint(Fstab* fstab, const std::string& path) {
-    if (fstab == nullptr) {
-        return nullptr;
-    }
-
-    for (auto& entry : *fstab) {
-        if (entry.mount_point == path) {
-            return &entry;
-        }
-    }
-
-    return nullptr;
-}
-
 std::vector<FstabEntry*> GetEntriesForMountPoint(Fstab* fstab, const std::string& path) {
     return GetEntriesByPred(fstab,
                             [&path](const FstabEntry& entry) { return entry.mount_point == path; });
 }
 
+std::vector<const FstabEntry*> GetEntriesForMountPoint(const Fstab* fstab,
+                                                       const std::string& path) {
+    return GetEntriesByPred(fstab,
+                            [&path](const FstabEntry& entry) { return entry.mount_point == path; });
+}
+
+FstabEntry* GetEntryForMountPoint(Fstab* fstab, const std::string& path) {
+    std::vector<FstabEntry*> entries = GetEntriesForMountPoint(fstab, path);
+    return entries.empty() ? nullptr : entries.front();
+}
+
+const FstabEntry* GetEntryForMountPoint(const Fstab* fstab, const std::string& path) {
+    std::vector<const FstabEntry*> entries = GetEntriesForMountPoint(fstab, path);
+    return entries.empty() ? nullptr : entries.front();
+}
+
 std::set<std::string> GetBootDevices() {
     // First check bootconfig, then kernel commandline, then the device tree
     std::string dt_file_name = get_android_dt_dir() + "/boot_devices";
diff --git a/fs_mgr/fs_mgr_overlayfs.cpp b/fs_mgr/fs_mgr_overlayfs.cpp
index bb24abf..0f2a75a 100644
--- a/fs_mgr/fs_mgr_overlayfs.cpp
+++ b/fs_mgr/fs_mgr_overlayfs.cpp
@@ -1351,7 +1351,8 @@
     return ret;
 }
 
-bool fs_mgr_overlayfs_setup(const char* mount_point, bool* want_reboot, bool just_disabled_verity) {
+bool fs_mgr_overlayfs_setup(const Fstab& fstab, const char* mount_point, bool* want_reboot,
+                            bool just_disabled_verity) {
     if (!OverlayfsSetupAllowed(/*verbose=*/true)) {
         return false;
     }
@@ -1361,12 +1362,6 @@
         return false;
     }
 
-    Fstab fstab;
-    if (!ReadDefaultFstab(&fstab)) {
-        LOG(ERROR) << "Could not read fstab";
-        return false;
-    }
-
     auto candidates = fs_mgr_overlayfs_candidate_list(fstab);
     for (auto it = candidates.begin(); it != candidates.end();) {
         if (mount_point &&
diff --git a/fs_mgr/fs_mgr_priv_overlayfs.h b/fs_mgr/fs_mgr_priv_overlayfs.h
index 45b954d..2033701 100644
--- a/fs_mgr/fs_mgr_priv_overlayfs.h
+++ b/fs_mgr/fs_mgr_priv_overlayfs.h
@@ -29,8 +29,8 @@
 //
 // If |want_reboot| is non-null, and a reboot is needed to apply overlays, then
 // it will be true on return. The caller is responsible for initializing it.
-bool fs_mgr_overlayfs_setup(const char* mount_point = nullptr, bool* want_reboot = nullptr,
-                            bool just_disabled_verity = true);
+bool fs_mgr_overlayfs_setup(const android::fs_mgr::Fstab& fstab, const char* mount_point = nullptr,
+                            bool* want_reboot = nullptr, bool just_disabled_verity = true);
 
 enum class OverlayfsTeardownResult {
     Ok,
diff --git a/fs_mgr/fs_mgr_remount.cpp b/fs_mgr/fs_mgr_remount.cpp
index 23bc8e8..5fddf86 100644
--- a/fs_mgr/fs_mgr_remount.cpp
+++ b/fs_mgr/fs_mgr_remount.cpp
@@ -289,7 +289,7 @@
         if (fs_mgr_wants_overlayfs(&entry)) {
             bool want_reboot = false;
             bool force = result->disabled_verity;
-            if (!fs_mgr_overlayfs_setup(mount_point.c_str(), &want_reboot, force)) {
+            if (!fs_mgr_overlayfs_setup(*partitions, mount_point.c_str(), &want_reboot, force)) {
                 LOG(ERROR) << "Overlayfs setup for " << mount_point << " failed, skipping";
                 ok = false;
                 it = partitions->erase(it);
@@ -442,7 +442,12 @@
 bool SetupOrTeardownOverlayfs(bool enable) {
     bool want_reboot = false;
     if (enable) {
-        if (!fs_mgr_overlayfs_setup(nullptr, &want_reboot)) {
+        Fstab fstab;
+        if (!ReadDefaultFstab(&fstab)) {
+            LOG(ERROR) << "Could not read fstab.";
+            return want_reboot;
+        }
+        if (!fs_mgr_overlayfs_setup(fstab, nullptr, &want_reboot)) {
             LOG(ERROR) << "Overlayfs setup failed.";
             return want_reboot;
         }
diff --git a/fs_mgr/include_fstab/fstab/fstab.h b/fs_mgr/include_fstab/fstab/fstab.h
index 124f070..a914b53 100644
--- a/fs_mgr/include_fstab/fstab/fstab.h
+++ b/fs_mgr/include_fstab/fstab/fstab.h
@@ -105,10 +105,13 @@
 bool ReadDefaultFstab(Fstab* fstab);
 bool SkipMountingPartitions(Fstab* fstab, bool verbose = false);
 
-FstabEntry* GetEntryForMountPoint(Fstab* fstab, const std::string& path);
 // The Fstab can contain multiple entries for the same mount point with different configurations.
 std::vector<FstabEntry*> GetEntriesForMountPoint(Fstab* fstab, const std::string& path);
 
+// Like GetEntriesForMountPoint() but return only the first entry or nullptr if no entry is found.
+FstabEntry* GetEntryForMountPoint(Fstab* fstab, const std::string& path);
+const FstabEntry* GetEntryForMountPoint(const Fstab* fstab, const std::string& path);
+
 // This method builds DSU fstab entries and transfer the fstab.
 //
 // fstab points to the unmodified fstab.
diff --git a/init/service.cpp b/init/service.cpp
index 78bf42f..d495b91 100644
--- a/init/service.cpp
+++ b/init/service.cpp
@@ -866,6 +866,8 @@
 
     if ((how != SVC_DISABLED) && (how != SVC_RESET) && (how != SVC_RESTART)) {
         // An illegal flag: default to SVC_DISABLED.
+        LOG(ERROR) << "service '" << name_ << "' requested unknown flag " << how
+                   << ", defaulting to disabling it.";
         how = SVC_DISABLED;
     }
 
diff --git a/trusty/keymaster/keymint/android.hardware.security.keymint-service.trusty.xml b/trusty/keymaster/keymint/android.hardware.security.keymint-service.trusty.xml
index 77dc854..3dc9c88 100644
--- a/trusty/keymaster/keymint/android.hardware.security.keymint-service.trusty.xml
+++ b/trusty/keymaster/keymint/android.hardware.security.keymint-service.trusty.xml
@@ -1,7 +1,7 @@
 <manifest version="1.0" type="device">
     <hal format="aidl">
         <name>android.hardware.security.keymint</name>
-        <version>2</version>
+        <version>3</version>
         <fqname>IKeyMintDevice/default</fqname>
     </hal>
     <hal format="aidl">