Merge "lmkd: bump process priority and set to FOREGROUND group before kill"
diff --git a/fs_mgr/fs_mgr.cpp b/fs_mgr/fs_mgr.cpp
index 9f6c550..785f9a2 100644
--- a/fs_mgr/fs_mgr.cpp
+++ b/fs_mgr/fs_mgr.cpp
@@ -954,6 +954,17 @@
std::map<std::string, std::string> device_map_;
};
+static bool IsMountPointMounted(const std::string& mount_point) {
+ // Check if this is already mounted.
+ Fstab fstab;
+ if (!ReadFstabFromFile("/proc/mounts", &fstab)) {
+ return false;
+ }
+ auto it = std::find_if(fstab.begin(), fstab.end(),
+ [&](const auto& entry) { return entry.mount_point == mount_point; });
+ return it != fstab.end();
+}
+
// When multiple fstab records share the same mount_point, it will try to mount each
// one in turn, and ignore any duplicates after a first successful mount.
// Returns -1 on error, and FS_MGR_MNTALL_* otherwise.
@@ -970,9 +981,18 @@
for (size_t i = 0; i < fstab->size(); i++) {
auto& current_entry = (*fstab)[i];
+ // If a filesystem should have been mounted in the first stage, we
+ // ignore it here. With one exception, if the filesystem is
+ // formattable, then it can only be formatted in the second stage,
+ // so we allow it to mount here.
+ if (current_entry.fs_mgr_flags.first_stage_mount &&
+ (!current_entry.fs_mgr_flags.formattable ||
+ IsMountPointMounted(current_entry.mount_point))) {
+ continue;
+ }
+
// Don't mount entries that are managed by vold or not for the mount mode.
if (current_entry.fs_mgr_flags.vold_managed || current_entry.fs_mgr_flags.recovery_only ||
- current_entry.fs_mgr_flags.first_stage_mount ||
((mount_mode == MOUNT_MODE_LATE) && !current_entry.fs_mgr_flags.late_mount) ||
((mount_mode == MOUNT_MODE_EARLY) && current_entry.fs_mgr_flags.late_mount)) {
continue;
diff --git a/fs_mgr/tests/adb-remount-test.sh b/fs_mgr/tests/adb-remount-test.sh
index a849578..825109f 100755
--- a/fs_mgr/tests/adb-remount-test.sh
+++ b/fs_mgr/tests/adb-remount-test.sh
@@ -378,7 +378,7 @@
D=`echo / /
echo "${D}" | grep -v /dev/root`
fi
-D=`echo "${D}" | cut -s -d' ' -f1`
+D=`echo "${D}" | cut -s -d' ' -f1 | sort -u`
D=`adb_sh df -k ${D} </dev/null`
echo "${D}"
if [ X"${D}" = X"${D##* 100[%] }" ]; then
@@ -506,7 +506,9 @@
echo "${D}" &&
echo "${D}" | grep "^overlay .* /system\$" >/dev/null ||
die "overlay takeover after remount"
- !(adb_sh grep "^overlay " /proc/mounts </dev/null | grep -v "^overlay /vendor/..* overlay ro," | grep " overlay ro,") &&
+ !(adb_sh grep "^overlay " /proc/mounts </dev/null |
+ grep -v "^overlay /\(vendor\|system\)/..* overlay ro," |
+ grep " overlay ro,") &&
!(adb_sh grep " rw," /proc/mounts </dev/null |
skip_administrative_mounts data) ||
die "remount overlayfs missed a spot (ro)"
diff --git a/init/README.md b/init/README.md
index 8d47e0a..3a7c71c 100644
--- a/init/README.md
+++ b/init/README.md
@@ -482,9 +482,8 @@
-f: force installation of the module even if the version of the running kernel
and the version of the kernel for which the module was compiled do not match.
-`load_all_props`
-> Loads properties from /system, /vendor, et cetera.
- This is included in the default init.rc.
+`load_system_props`
+> (This action is deprecated and no-op.)
`load_persist_props`
> Loads persistent properties when /data has been decrypted.
diff --git a/init/builtins.cpp b/init/builtins.cpp
index 4a66e46..43a520f 100644
--- a/init/builtins.cpp
+++ b/init/builtins.cpp
@@ -972,7 +972,7 @@
}
static Result<Success> do_load_system_props(const BuiltinArguments& args) {
- load_system_props();
+ LOG(INFO) << "deprecated action `load_system_props` called.";
return Success();
}
diff --git a/init/property_service.cpp b/init/property_service.cpp
index 5328869..3199d45 100644
--- a/init/property_service.cpp
+++ b/init/property_service.cpp
@@ -699,22 +699,6 @@
}
}
-void property_load_boot_defaults() {
- if (!load_properties_from_file("/system/etc/prop.default", NULL)) {
- // Try recovery path
- if (!load_properties_from_file("/prop.default", NULL)) {
- // Try legacy path
- load_properties_from_file("/default.prop", NULL);
- }
- }
- load_properties_from_file("/product/build.prop", NULL);
- load_properties_from_file("/product_services/build.prop", NULL);
- load_properties_from_file("/odm/default.prop", NULL);
- load_properties_from_file("/vendor/default.prop", NULL);
-
- update_sys_usb_config();
-}
-
static void load_override_properties() {
if (ALLOW_LOCAL_PROP_OVERRIDE) {
load_properties_from_file("/data/local.prop", NULL);
@@ -779,12 +763,29 @@
close(fd);
}
-void load_system_props() {
+void property_load_boot_defaults() {
+ // TODO(b/117892318): merge prop.default and build.prop files into one
+ // TODO(b/122864654): read the prop files from all partitions and then
+ // resolve the duplication by their origin so that RO and non-RO properties
+ // have a consistent overriding order.
+ if (!load_properties_from_file("/system/etc/prop.default", NULL)) {
+ // Try recovery path
+ if (!load_properties_from_file("/prop.default", NULL)) {
+ // Try legacy path
+ load_properties_from_file("/default.prop", NULL);
+ }
+ }
+ load_properties_from_file("/product/build.prop", NULL);
+ load_properties_from_file("/product_services/build.prop", NULL);
+ load_properties_from_file("/odm/default.prop", NULL);
+ load_properties_from_file("/vendor/default.prop", NULL);
load_properties_from_file("/system/build.prop", NULL);
load_properties_from_file("/odm/build.prop", NULL);
load_properties_from_file("/vendor/build.prop", NULL);
load_properties_from_file("/factory/factory.prop", "ro.*");
load_recovery_id_prop();
+
+ update_sys_usb_config();
}
static int SelinuxAuditCallback(void* data, security_class_t /*cls*/, char* buf, size_t len) {
diff --git a/init/service.cpp b/init/service.cpp
index eec55c3..f3eafe4 100644
--- a/init/service.cpp
+++ b/init/service.cpp
@@ -406,7 +406,7 @@
// If we crash > 4 times in 4 minutes, reboot into bootloader or set crashing property
boot_clock::time_point now = boot_clock::now();
- if (((flags_ & SVC_CRITICAL) || classnames_.count("updatable")) && !(flags_ & SVC_RESTART)) {
+ if (((flags_ & SVC_CRITICAL) || !pre_apexd_) && !(flags_ & SVC_RESTART)) {
if (now < time_crashed_ + 4min) {
if (++crash_count_ > 4) {
if (flags_ & SVC_CRITICAL) {
diff --git a/libmeminfo/libmeminfo_test.cpp b/libmeminfo/libmeminfo_test.cpp
index e689a26..7d85dd2 100644
--- a/libmeminfo/libmeminfo_test.cpp
+++ b/libmeminfo/libmeminfo_test.cpp
@@ -293,15 +293,6 @@
EXPECT_EQ(supported, IsSmapsRollupSupported(-1));
}
-TEST(TestProcMemInfo, SmapsOrRollupReturn) {
- // if /proc/<pid>/smaps_rollup file exists, .SmapsRollup() must return true;
- // false otherwise
- std::string path = ::android::base::StringPrintf("/proc/%d/smaps_rollup", pid);
- ProcMemInfo proc_mem(pid);
- MemUsage stats;
- EXPECT_EQ(!access(path.c_str(), F_OK), proc_mem.SmapsOrRollup(&stats));
-}
-
TEST(TestProcMemInfo, SmapsOrRollupTest) {
std::string rollup =
R"rollup(12c00000-7fe859e000 ---p 00000000 00:00 0 [rollup]
diff --git a/libmeminfo/procmeminfo.cpp b/libmeminfo/procmeminfo.cpp
index 347a293..d6332a3 100644
--- a/libmeminfo/procmeminfo.cpp
+++ b/libmeminfo/procmeminfo.cpp
@@ -406,9 +406,10 @@
return false;
}
- char line[1024];
+ char* line = nullptr;
+ size_t line_alloc = 0;
stats->clear();
- while (fgets(line, sizeof(line), fp.get()) != nullptr) {
+ while (getline(&line, &line_alloc, fp.get()) > 0) {
switch (line[0]) {
case 'P':
if (strncmp(line, "Pss:", 4) == 0) {
@@ -441,6 +442,8 @@
}
}
+ // free getline() managed buffer
+ free(line);
return true;
}
@@ -450,14 +453,17 @@
return false;
}
*pss = 0;
- char line[1024];
- while (fgets(line, sizeof(line), fp.get()) != nullptr) {
+ char* line = nullptr;
+ size_t line_alloc = 0;
+ while (getline(&line, &line_alloc, fp.get()) > 0) {
uint64_t v;
if (sscanf(line, "Pss: %" SCNu64 " kB", &v) == 1) {
*pss += v;
}
}
+ // free getline() managed buffer
+ free(line);
return true;
}
diff --git a/libnativebridge/Android.bp b/libnativebridge/Android.bp
index 59cd033..c54570e 100644
--- a/libnativebridge/Android.bp
+++ b/libnativebridge/Android.bp
@@ -17,6 +17,15 @@
"liblog",
],
+ target: {
+ android: {
+ version_script: "libnativebridge.map.txt",
+ },
+ linux: {
+ version_script: "libnativebridge.map.txt",
+ },
+ },
+
stubs: {
symbol_file: "libnativebridge.map.txt",
versions: ["1"],
diff --git a/lmkd/tests/Android.bp b/lmkd/tests/Android.bp
index cbf44e9..4e845fd 100644
--- a/lmkd/tests/Android.bp
+++ b/lmkd/tests/Android.bp
@@ -18,6 +18,7 @@
shared_libs: [
"libbase",
"liblog",
+ "libcutils",
],
static_libs: [
diff --git a/rootdir/init.rc b/rootdir/init.rc
index b34399d..9b20964 100644
--- a/rootdir/init.rc
+++ b/rootdir/init.rc
@@ -346,12 +346,6 @@
trigger boot
on post-fs
- # Load properties from
- # /system/build.prop,
- # /odm/build.prop,
- # /vendor/build.prop and
- # /factory/factory.prop
- load_system_props
start vold
exec - system system -- /system/bin/vdc checkpoint markBootAttempt