Merge "Require liblog for libbase in all configurations"
diff --git a/Android.bp b/Android.bp
index c6f6251..0b4a925 100644
--- a/Android.bp
+++ b/Android.bp
@@ -2,5 +2,3 @@
name: "android_filesystem_config_header",
srcs: ["include/private/android_filesystem_config.h"],
}
-
-subdirs = ["*"]
diff --git a/adb/adb.h b/adb/adb.h
index e7fcc91..7f7dd0d 100644
--- a/adb/adb.h
+++ b/adb/adb.h
@@ -185,14 +185,7 @@
} while (0)
#endif
-#if ADB_HOST_ON_TARGET
-/* adb and adbd are coexisting on the target, so use 5038 for adb
- * to avoid conflicting with adbd's usage of 5037
- */
-#define DEFAULT_ADB_PORT 5038
-#else
#define DEFAULT_ADB_PORT 5037
-#endif
#define DEFAULT_ADB_LOCAL_TRANSPORT_PORT 5555
diff --git a/adb/apex/ld.config.txt b/adb/apex/ld.config.txt
index 13d66b6..d1858a4 100644
--- a/adb/apex/ld.config.txt
+++ b/adb/apex/ld.config.txt
@@ -10,6 +10,8 @@
namespace.default.isolated = true
namespace.default.search.paths = /apex/com.android.adbd/${LIB}
namespace.default.asan.search.paths = /apex/com.android.adbd/${LIB}
+namespace.default.permitted.paths = /system/${LIB}
+namespace.default.asan.permitted.paths = /system/${LIB}
namespace.default.links = art,platform
namespace.default.link.art.shared_libs = libadbconnection_server.so
namespace.default.link.platform.shared_libs = libc.so:libdl.so:libm.so:libclang_rt.hwasan-aarch64-android.so
diff --git a/adb/client/commandline.cpp b/adb/client/commandline.cpp
index 680173a..83b9238 100644
--- a/adb/client/commandline.cpp
+++ b/adb/client/commandline.cpp
@@ -1621,7 +1621,7 @@
return adb_query_command(query);
}
else if (!strcmp(argv[0], "connect")) {
- if (argc != 2) error_exit("usage: adb connect HOST[:PORT>]");
+ if (argc != 2) error_exit("usage: adb connect HOST[:PORT]");
std::string query = android::base::StringPrintf("host:connect:%s", argv[1]);
return adb_query_command(query);
diff --git a/base/include/android-base/logging.h b/base/include/android-base/logging.h
index f4a4c5d..3a9186a 100644
--- a/base/include/android-base/logging.h
+++ b/base/include/android-base/logging.h
@@ -220,20 +220,16 @@
// 1) This will not check whether the severity is high enough. One should use WOULD_LOG to filter
// usage manually.
// 2) This does not save and restore errno.
-#define LOG_STREAM(severity) LOG_STREAM_TO(DEFAULT, severity)
-
-// Get an ostream that can be used for logging at the given severity and to the
-// given destination. The same notes as for LOG_STREAM apply.
-#define LOG_STREAM_TO(dest, severity) \
- ::android::base::LogMessage(__FILE__, __LINE__, ::android::base::dest, \
- SEVERITY_LAMBDA(severity), _LOG_TAG_INTERNAL, -1) \
+#define LOG_STREAM(severity) \
+ ::android::base::LogMessage(__FILE__, __LINE__, SEVERITY_LAMBDA(severity), _LOG_TAG_INTERNAL, \
+ -1) \
.stream()
// Logs a message to logcat on Android otherwise to stderr. If the severity is
// FATAL it also causes an abort. For example:
//
// LOG(FATAL) << "We didn't expect to reach here";
-#define LOG(severity) LOG_TO(DEFAULT, severity)
+#define LOG(severity) LOGGING_PREAMBLE(severity) && LOG_STREAM(severity)
// Checks if we want to log something, and sets up appropriate RAII objects if
// so.
@@ -243,21 +239,12 @@
ABORT_AFTER_LOG_EXPR_IF((SEVERITY_LAMBDA(severity)) == ::android::base::FATAL, true) && \
::android::base::ErrnoRestorer())
-// Logs a message to logcat with the specified log ID on Android otherwise to
-// stderr. If the severity is FATAL it also causes an abort.
-// Use an expression here so we can support the << operator following the macro,
-// like "LOG(DEBUG) << xxx;".
-#define LOG_TO(dest, severity) LOGGING_PREAMBLE(severity) && LOG_STREAM_TO(dest, severity)
-
// A variant of LOG that also logs the current errno value. To be used when
// library calls fail.
-#define PLOG(severity) PLOG_TO(DEFAULT, severity)
-
-// Behaves like PLOG, but logs to the specified log ID.
-#define PLOG_TO(dest, severity) \
- LOGGING_PREAMBLE(severity) && \
- ::android::base::LogMessage(__FILE__, __LINE__, ::android::base::dest, \
- SEVERITY_LAMBDA(severity), _LOG_TAG_INTERNAL, errno) \
+#define PLOG(severity) \
+ LOGGING_PREAMBLE(severity) && \
+ ::android::base::LogMessage(__FILE__, __LINE__, SEVERITY_LAMBDA(severity), \
+ _LOG_TAG_INTERNAL, errno) \
.stream()
// Marker that code is yet to be implemented.
@@ -270,24 +257,23 @@
//
// CHECK(false == true) results in a log message of
// "Check failed: false == true".
-#define CHECK(x) \
- LIKELY((x)) || ABORT_AFTER_LOG_FATAL_EXPR(false) || \
- ::android::base::LogMessage(__FILE__, __LINE__, ::android::base::DEFAULT, \
- ::android::base::FATAL, _LOG_TAG_INTERNAL, -1) \
- .stream() \
+#define CHECK(x) \
+ LIKELY((x)) || ABORT_AFTER_LOG_FATAL_EXPR(false) || \
+ ::android::base::LogMessage(__FILE__, __LINE__, ::android::base::FATAL, _LOG_TAG_INTERNAL, \
+ -1) \
+ .stream() \
<< "Check failed: " #x << " "
// clang-format off
// Helper for CHECK_xx(x,y) macros.
-#define CHECK_OP(LHS, RHS, OP) \
- for (auto _values = ::android::base::MakeEagerEvaluator(LHS, RHS); \
- UNLIKELY(!(_values.lhs OP _values.rhs)); \
- /* empty */) \
- ABORT_AFTER_LOG_FATAL \
- ::android::base::LogMessage(__FILE__, __LINE__, ::android::base::DEFAULT, \
- ::android::base::FATAL, _LOG_TAG_INTERNAL, -1) \
- .stream() \
- << "Check failed: " << #LHS << " " << #OP << " " << #RHS << " (" #LHS "=" << _values.lhs \
+#define CHECK_OP(LHS, RHS, OP) \
+ for (auto _values = ::android::base::MakeEagerEvaluator(LHS, RHS); \
+ UNLIKELY(!(_values.lhs OP _values.rhs)); \
+ /* empty */) \
+ ABORT_AFTER_LOG_FATAL \
+ ::android::base::LogMessage(__FILE__, __LINE__, ::android::base::FATAL, _LOG_TAG_INTERNAL, -1) \
+ .stream() \
+ << "Check failed: " << #LHS << " " << #OP << " " << #RHS << " (" #LHS "=" << _values.lhs \
<< ", " #RHS "=" << _values.rhs << ") "
// clang-format on
@@ -309,8 +295,8 @@
#define CHECK_STROP(s1, s2, sense) \
while (UNLIKELY((strcmp(s1, s2) == 0) != (sense))) \
ABORT_AFTER_LOG_FATAL \
- ::android::base::LogMessage(__FILE__, __LINE__, ::android::base::DEFAULT, \
- ::android::base::FATAL, _LOG_TAG_INTERNAL, -1) \
+ ::android::base::LogMessage(__FILE__, __LINE__, ::android::base::FATAL, \
+ _LOG_TAG_INTERNAL, -1) \
.stream() \
<< "Check failed: " << "\"" << (s1) << "\"" \
<< ((sense) ? " == " : " != ") << "\"" << (s2) << "\""
@@ -429,8 +415,10 @@
// of a CHECK. The destructor will abort if the severity is FATAL.
class LogMessage {
public:
- LogMessage(const char* file, unsigned int line, LogId id, LogSeverity severity, const char* tag,
+ // LogId has been deprecated, but this constructor must exist for prebuilts.
+ LogMessage(const char* file, unsigned int line, LogId, LogSeverity severity, const char* tag,
int error);
+ LogMessage(const char* file, unsigned int line, LogSeverity severity, const char* tag, int error);
~LogMessage();
@@ -439,8 +427,8 @@
std::ostream& stream();
// The routine that performs the actual logging.
- static void LogLine(const char* file, unsigned int line, LogId id, LogSeverity severity,
- const char* tag, const char* msg);
+ static void LogLine(const char* file, unsigned int line, LogSeverity severity, const char* tag,
+ const char* msg);
private:
const std::unique_ptr<LogMessageData> data_;
diff --git a/base/include/android-base/unique_fd.h b/base/include/android-base/unique_fd.h
index 1605daf..c4a0aad 100644
--- a/base/include/android-base/unique_fd.h
+++ b/base/include/android-base/unique_fd.h
@@ -116,6 +116,8 @@
bool operator<(int rhs) const { return get() < rhs; }
bool operator==(int rhs) const { return get() == rhs; }
bool operator!=(int rhs) const { return get() != rhs; }
+ bool operator==(const unique_fd_impl& rhs) const { return get() == rhs.get(); }
+ bool operator!=(const unique_fd_impl& rhs) const { return get() != rhs.get(); }
// Catch bogus error checks (i.e.: "!fd" instead of "fd != -1").
bool operator!() const = delete;
diff --git a/base/logging.cpp b/base/logging.cpp
index 643cdf0..b46abbf 100644
--- a/base/logging.cpp
+++ b/base/logging.cpp
@@ -348,11 +348,10 @@
// checks/logging in a function.
class LogMessageData {
public:
- LogMessageData(const char* file, unsigned int line, LogId id, LogSeverity severity,
- const char* tag, int error)
+ LogMessageData(const char* file, unsigned int line, LogSeverity severity, const char* tag,
+ int error)
: file_(GetFileBasename(file)),
line_number_(line),
- id_(id),
severity_(severity),
tag_(tag),
error_(error) {}
@@ -371,10 +370,6 @@
const char* GetTag() const { return tag_; }
- LogId GetId() const {
- return id_;
- }
-
int GetError() const {
return error_;
}
@@ -391,7 +386,6 @@
std::ostringstream buffer_;
const char* const file_;
const unsigned int line_number_;
- const LogId id_;
const LogSeverity severity_;
const char* const tag_;
const int error_;
@@ -399,9 +393,13 @@
DISALLOW_COPY_AND_ASSIGN(LogMessageData);
};
-LogMessage::LogMessage(const char* file, unsigned int line, LogId id, LogSeverity severity,
+LogMessage::LogMessage(const char* file, unsigned int line, LogId, LogSeverity severity,
const char* tag, int error)
- : data_(new LogMessageData(file, line, id, severity, tag, error)) {}
+ : LogMessage(file, line, severity, tag, error) {}
+
+LogMessage::LogMessage(const char* file, unsigned int line, LogSeverity severity, const char* tag,
+ int error)
+ : data_(new LogMessageData(file, line, severity, tag, error)) {}
LogMessage::~LogMessage() {
// Check severity again. This is duplicate work wrt/ LOG macros, but not LOG_STREAM.
@@ -427,16 +425,16 @@
// Do the actual logging with the lock held.
std::lock_guard<std::mutex> lock(LoggingLock());
if (msg.find('\n') == std::string::npos) {
- LogLine(data_->GetFile(), data_->GetLineNumber(), data_->GetId(), data_->GetSeverity(),
- data_->GetTag(), msg.c_str());
+ LogLine(data_->GetFile(), data_->GetLineNumber(), data_->GetSeverity(), data_->GetTag(),
+ msg.c_str());
} else {
msg += '\n';
size_t i = 0;
while (i < msg.size()) {
size_t nl = msg.find('\n', i);
msg[nl] = '\0';
- LogLine(data_->GetFile(), data_->GetLineNumber(), data_->GetId(), data_->GetSeverity(),
- data_->GetTag(), &msg[i]);
+ LogLine(data_->GetFile(), data_->GetLineNumber(), data_->GetSeverity(), data_->GetTag(),
+ &msg[i]);
// Undo the zero-termination so we can give the complete message to the aborter.
msg[nl] = '\n';
i = nl + 1;
@@ -454,16 +452,16 @@
return data_->GetBuffer();
}
-void LogMessage::LogLine(const char* file, unsigned int line, LogId id, LogSeverity severity,
- const char* tag, const char* message) {
+void LogMessage::LogLine(const char* file, unsigned int line, LogSeverity severity, const char* tag,
+ const char* message) {
if (tag == nullptr) {
std::lock_guard<std::recursive_mutex> lock(TagLock());
if (gDefaultTag == nullptr) {
gDefaultTag = new std::string(getprogname());
}
- Logger()(id, severity, gDefaultTag->c_str(), file, line, message);
+ Logger()(DEFAULT, severity, gDefaultTag->c_str(), file, line, message);
} else {
- Logger()(id, severity, tag, file, line, message);
+ Logger()(DEFAULT, severity, tag, file, line, message);
}
}
diff --git a/debuggerd/Android.bp b/debuggerd/Android.bp
index 780e48d..c8df3e3 100644
--- a/debuggerd/Android.bp
+++ b/debuggerd/Android.bp
@@ -355,7 +355,3 @@
init_rc: ["tombstoned/tombstoned.rc"],
}
-
-subdirs = [
- "crasher",
-]
diff --git a/deprecated-adf/Android.bp b/deprecated-adf/Android.bp
deleted file mode 100644
index b44c296..0000000
--- a/deprecated-adf/Android.bp
+++ /dev/null
@@ -1 +0,0 @@
-subdirs = ["*"]
diff --git a/deprecated-adf/libadf/Android.bp b/deprecated-adf/libadf/Android.bp
index 49e3721..70f0a3b 100644
--- a/deprecated-adf/libadf/Android.bp
+++ b/deprecated-adf/libadf/Android.bp
@@ -24,5 +24,3 @@
local_include_dirs: ["include"],
export_include_dirs: ["include"],
}
-
-subdirs = ["tests"]
diff --git a/fastboot/device/commands.cpp b/fastboot/device/commands.cpp
index 1a745ab..b7263d9 100644
--- a/fastboot/device/commands.cpp
+++ b/fastboot/device/commands.cpp
@@ -31,7 +31,6 @@
#include <cutils/android_reboot.h>
#include <ext4_utils/wipe.h>
#include <fs_mgr.h>
-#include <fs_mgr/roots.h>
#include <libgsi/libgsi.h>
#include <liblp/builder.h>
#include <liblp/liblp.h>
@@ -550,42 +549,6 @@
return UpdateSuper(device, args[1], wipe);
}
-class AutoMountMetadata {
- public:
- AutoMountMetadata() {
- android::fs_mgr::Fstab proc_mounts;
- if (!ReadFstabFromFile("/proc/mounts", &proc_mounts)) {
- LOG(ERROR) << "Could not read /proc/mounts";
- return;
- }
-
- auto iter = std::find_if(proc_mounts.begin(), proc_mounts.end(),
- [](const auto& entry) { return entry.mount_point == "/metadata"; });
- if (iter != proc_mounts.end()) {
- mounted_ = true;
- return;
- }
-
- if (!ReadDefaultFstab(&fstab_)) {
- LOG(ERROR) << "Could not read default fstab";
- return;
- }
- mounted_ = EnsurePathMounted(&fstab_, "/metadata");
- should_unmount_ = true;
- }
- ~AutoMountMetadata() {
- if (mounted_ && should_unmount_) {
- EnsurePathUnmounted(&fstab_, "/metadata");
- }
- }
- explicit operator bool() const { return mounted_; }
-
- private:
- android::fs_mgr::Fstab fstab_;
- bool mounted_ = false;
- bool should_unmount_ = false;
-};
-
bool GsiHandler(FastbootDevice* device, const std::vector<std::string>& args) {
if (args.size() != 2) {
return device->WriteFail("Invalid arguments");
diff --git a/fastboot/device/flashing.cpp b/fastboot/device/flashing.cpp
index 102ebdb..7e7e507 100644
--- a/fastboot/device/flashing.cpp
+++ b/fastboot/device/flashing.cpp
@@ -21,6 +21,7 @@
#include <algorithm>
#include <memory>
+#include <optional>
#include <set>
#include <string>
@@ -56,6 +57,7 @@
Fstab fstab;
ReadDefaultFstab(&fstab);
+ std::optional<AutoMountMetadata> mount_metadata;
for (const auto& entry : fstab) {
auto partition = android::base::Basename(entry.mount_point);
if ("/" == entry.mount_point) {
@@ -63,6 +65,7 @@
}
if ((partition + device->GetCurrentSlot()) == partition_name) {
+ mount_metadata.emplace();
fs_mgr_overlayfs_teardown(entry.mount_point.c_str());
}
}
diff --git a/fastboot/device/utility.cpp b/fastboot/device/utility.cpp
index b3f2d5f..7c6ac89 100644
--- a/fastboot/device/utility.cpp
+++ b/fastboot/device/utility.cpp
@@ -26,6 +26,7 @@
#include <android-base/properties.h>
#include <android-base/strings.h>
#include <fs_mgr.h>
+#include <fs_mgr/roots.h>
#include <fs_mgr_dm_linear.h>
#include <liblp/builder.h>
#include <liblp/liblp.h>
@@ -240,3 +241,29 @@
}
return current_slot_suffix;
}
+
+AutoMountMetadata::AutoMountMetadata() {
+ android::fs_mgr::Fstab proc_mounts;
+ if (!ReadFstabFromFile("/proc/mounts", &proc_mounts)) {
+ LOG(ERROR) << "Could not read /proc/mounts";
+ return;
+ }
+
+ if (GetEntryForMountPoint(&proc_mounts, "/metadata")) {
+ mounted_ = true;
+ return;
+ }
+
+ if (!ReadDefaultFstab(&fstab_)) {
+ LOG(ERROR) << "Could not read default fstab";
+ return;
+ }
+ mounted_ = EnsurePathMounted(&fstab_, "/metadata");
+ should_unmount_ = true;
+}
+
+AutoMountMetadata::~AutoMountMetadata() {
+ if (mounted_ && should_unmount_) {
+ EnsurePathUnmounted(&fstab_, "/metadata");
+ }
+}
diff --git a/fastboot/device/utility.h b/fastboot/device/utility.h
index bfeeb74..3b71ef0 100644
--- a/fastboot/device/utility.h
+++ b/fastboot/device/utility.h
@@ -20,6 +20,7 @@
#include <android-base/unique_fd.h>
#include <android/hardware/boot/1.0/IBootControl.h>
+#include <fstab/fstab.h>
#include <liblp/liblp.h>
// Logical partitions are only mapped to a block device as needed, and
@@ -51,6 +52,18 @@
std::function<void()> closer_;
};
+class AutoMountMetadata {
+ public:
+ AutoMountMetadata();
+ ~AutoMountMetadata();
+ explicit operator bool() const { return mounted_; }
+
+ private:
+ android::fs_mgr::Fstab fstab_;
+ bool mounted_ = false;
+ bool should_unmount_ = false;
+};
+
class FastbootDevice;
// On normal devices, the super partition is always named "super". On retrofit
diff --git a/fastboot/fuzzy_fastboot/Android.bp b/fastboot/fuzzy_fastboot/Android.bp
index 19b33e4..d48cfa9 100644
--- a/fastboot/fuzzy_fastboot/Android.bp
+++ b/fastboot/fuzzy_fastboot/Android.bp
@@ -31,6 +31,8 @@
"libext4_utils",
],
+ stl: "libc++_static",
+
// Static libs (libfastboot2) shared library dependencies are not transitively included
// This is needed to avoid link time errors when building for mac
target: {
diff --git a/fs_mgr/fs_mgr.cpp b/fs_mgr/fs_mgr.cpp
index 15c9dfb..03c7943 100644
--- a/fs_mgr/fs_mgr.cpp
+++ b/fs_mgr/fs_mgr.cpp
@@ -910,6 +910,10 @@
return true;
}
+static bool SupportsCheckpoint(FstabEntry* entry) {
+ return entry->fs_mgr_flags.checkpoint_blk || entry->fs_mgr_flags.checkpoint_fs;
+}
+
class CheckpointManager {
public:
CheckpointManager(int needs_checkpoint = -1) : needs_checkpoint_(needs_checkpoint) {}
@@ -926,7 +930,7 @@
}
bool Update(FstabEntry* entry, const std::string& block_device = std::string()) {
- if (!entry->fs_mgr_flags.checkpoint_blk && !entry->fs_mgr_flags.checkpoint_fs) {
+ if (!SupportsCheckpoint(entry)) {
return true;
}
@@ -947,7 +951,7 @@
}
bool Revert(FstabEntry* entry) {
- if (!entry->fs_mgr_flags.checkpoint_blk && !entry->fs_mgr_flags.checkpoint_fs) {
+ if (!SupportsCheckpoint(entry)) {
return true;
}
@@ -1362,6 +1366,7 @@
}
static bool fs_mgr_unmount_all_data_mounts(const std::string& block_device) {
+ LINFO << __FUNCTION__ << "(): about to umount everything on top of " << block_device;
Timer t;
// TODO(b/135984674): should be configured via a read-only property.
std::chrono::milliseconds timeout = 5s;
@@ -1369,22 +1374,34 @@
bool umount_done = true;
Fstab proc_mounts;
if (!ReadFstabFromFile("/proc/mounts", &proc_mounts)) {
- LERROR << "Can't read /proc/mounts";
+ LERROR << __FUNCTION__ << "(): Can't read /proc/mounts";
return false;
}
// Now proceed with other bind mounts on top of /data.
for (const auto& entry : proc_mounts) {
if (entry.blk_device == block_device) {
if (umount2(entry.mount_point.c_str(), 0) != 0) {
+ PERROR << __FUNCTION__ << "(): Failed to umount " << entry.mount_point;
umount_done = false;
}
}
}
if (umount_done) {
- LINFO << "Unmounting /data took " << t;
+ LINFO << __FUNCTION__ << "(): Unmounting /data took " << t;
return true;
}
if (t.duration() > timeout) {
+ LERROR << __FUNCTION__ << "(): Timed out unmounting all mounts on " << block_device;
+ Fstab remaining_mounts;
+ if (!ReadFstabFromFile("/proc/mounts", &remaining_mounts)) {
+ LERROR << __FUNCTION__ << "(): Can't read /proc/mounts";
+ } else {
+ LERROR << __FUNCTION__ << "(): Following mounts remaining";
+ for (const auto& e : remaining_mounts) {
+ LERROR << __FUNCTION__ << "(): mount point: " << e.mount_point
+ << " block device: " << e.blk_device;
+ }
+ }
return false;
}
std::this_thread::sleep_for(50ms);
@@ -1410,18 +1427,20 @@
LERROR << "Can't find /data in fstab";
return -1;
}
- if (!fstab_entry->fs_mgr_flags.checkpoint_blk && !fstab_entry->fs_mgr_flags.checkpoint_fs) {
+ bool force_umount = GetBoolProperty("sys.init.userdata_remount.force_umount", false);
+ if (force_umount) {
+ LINFO << "Will force an umount of userdata even if it's not required";
+ }
+ if (!force_umount && !SupportsCheckpoint(fstab_entry)) {
LINFO << "Userdata doesn't support checkpointing. Nothing to do";
return 0;
}
CheckpointManager checkpoint_manager;
- if (!checkpoint_manager.NeedsCheckpoint()) {
+ if (!force_umount && !checkpoint_manager.NeedsCheckpoint()) {
LINFO << "Checkpointing not needed. Don't remount";
return 0;
}
- bool force_umount_for_f2fs =
- GetBoolProperty("sys.init.userdata_remount.force_umount_f2fs", false);
- if (fstab_entry->fs_mgr_flags.checkpoint_fs && !force_umount_for_f2fs) {
+ if (!force_umount && fstab_entry->fs_mgr_flags.checkpoint_fs) {
// Userdata is f2fs, simply remount it.
if (!checkpoint_manager.Update(fstab_entry)) {
LERROR << "Failed to remount userdata in checkpointing mode";
diff --git a/fs_mgr/libfiemap/Android.bp b/fs_mgr/libfiemap/Android.bp
index e2df862..1bf457f 100644
--- a/fs_mgr/libfiemap/Android.bp
+++ b/fs_mgr/libfiemap/Android.bp
@@ -79,6 +79,11 @@
srcs: [
"fiemap_writer_test.cpp",
],
+
+ test_suites: ["vts-core", "device-tests"],
+ auto_gen_config: true,
+ test_min_api_level: 29,
+ require_root: true,
}
cc_test {
@@ -100,7 +105,3 @@
"image_test.cpp",
],
}
-
-vts_config {
- name: "VtsFiemapWriterTest",
-}
diff --git a/fs_mgr/libfiemap/AndroidTest.xml b/fs_mgr/libfiemap/AndroidTest.xml
deleted file mode 100644
index 44c80fc..0000000
--- a/fs_mgr/libfiemap/AndroidTest.xml
+++ /dev/null
@@ -1,30 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2019 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<configuration description="Config for VTS VtsFiemapWriterTest">
- <option name="config-descriptor:metadata" key="plan" value="vts-kernel" />
- <target_preparer class="com.android.compatibility.common.tradefed.targetprep.VtsFilePusher">
- <option name="abort-on-push-failure" value="false"/>
- <option name="push-group" value="HostDrivenTest.push"/>
- </target_preparer>
- <test class="com.android.tradefed.testtype.VtsMultiDeviceTest">
- <option name="test-module-name" value="VtsFiemapWriterTest"/>
- <option name="binary-test-source" value="_32bit::DATA/nativetest/fiemap_writer_test/fiemap_writer_test" />
- <option name="binary-test-source" value="_64bit::DATA/nativetest64/fiemap_writer_test/fiemap_writer_test" />
- <option name="binary-test-type" value="gtest"/>
- <option name="precondition-first-api-level" value="29" />
- <option name="test-timeout" value="1m"/>
- </test>
-</configuration>
diff --git a/fs_mgr/libsnapshot/Android.bp b/fs_mgr/libsnapshot/Android.bp
index eadcecc..9e67c66 100644
--- a/fs_mgr/libsnapshot/Android.bp
+++ b/fs_mgr/libsnapshot/Android.bp
@@ -127,6 +127,7 @@
"include_test",
],
srcs: [
+ "android/snapshot/snapshot.proto",
"test_helpers.cpp",
],
shared_libs: [
diff --git a/fs_mgr/libsnapshot/OWNERS b/fs_mgr/libsnapshot/OWNERS
index 0cfa7e4..801c446 100644
--- a/fs_mgr/libsnapshot/OWNERS
+++ b/fs_mgr/libsnapshot/OWNERS
@@ -1,2 +1,3 @@
+balsini@google.com
dvander@google.com
elsk@google.com
diff --git a/fs_mgr/libsnapshot/android/snapshot/snapshot.proto b/fs_mgr/libsnapshot/android/snapshot/snapshot.proto
index 629c3a4..a3a518d 100644
--- a/fs_mgr/libsnapshot/android/snapshot/snapshot.proto
+++ b/fs_mgr/libsnapshot/android/snapshot/snapshot.proto
@@ -85,3 +85,49 @@
// This is non-zero when |state| == MERGING or MERGE_COMPLETED.
uint64 metadata_sectors = 8;
}
+
+// Next: 8
+enum UpdateState {
+ // No update or merge is in progress.
+ None = 0;
+
+ // An update is applying; snapshots may already exist.
+ Initiated = 1;
+
+ // An update is pending, but has not been successfully booted yet.
+ Unverified = 2;
+
+ // The kernel is merging in the background.
+ Merging = 3;
+
+ // Post-merge cleanup steps could not be completed due to a transient
+ // error, but the next reboot will finish any pending operations.
+ MergeNeedsReboot = 4;
+
+ // Merging is complete, and needs to be acknowledged.
+ MergeCompleted = 5;
+
+ // Merging failed due to an unrecoverable error.
+ MergeFailed = 6;
+
+ // The update was implicitly cancelled, either by a rollback or a flash
+ // operation via fastboot. This state can only be returned by WaitForMerge.
+ Cancelled = 7;
+};
+
+// Next: 5
+message SnapshotUpdateStatus {
+ UpdateState state = 1;
+
+ // Total number of sectors allocated in the COW files before performing the
+ // merge operation. This field is used to keep track of the total number
+ // of sectors modified to monitor and show the progress of the merge during
+ // an update.
+ uint64 sectors_allocated = 2;
+
+ // Total number of sectors of all the snapshot devices.
+ uint64 total_sectors = 3;
+
+ // Sectors allocated for metadata in all the snapshot devices.
+ uint64 metadata_sectors = 4;
+}
diff --git a/fs_mgr/libsnapshot/include/libsnapshot/snapshot.h b/fs_mgr/libsnapshot/include/libsnapshot/snapshot.h
index 6e613ba..61946f7 100644
--- a/fs_mgr/libsnapshot/include/libsnapshot/snapshot.h
+++ b/fs_mgr/libsnapshot/include/libsnapshot/snapshot.h
@@ -26,6 +26,7 @@
#include <vector>
#include <android-base/unique_fd.h>
+#include <android/snapshot/snapshot.pb.h>
#include <fs_mgr_dm_linear.h>
#include <libdm/dm.h>
#include <libfiemap/image_manager.h>
@@ -80,35 +81,6 @@
NOT_CREATED,
};
-enum class UpdateState : unsigned int {
- // No update or merge is in progress.
- None,
-
- // An update is applying; snapshots may already exist.
- Initiated,
-
- // An update is pending, but has not been successfully booted yet.
- Unverified,
-
- // The kernel is merging in the background.
- Merging,
-
- // Post-merge cleanup steps could not be completed due to a transient
- // error, but the next reboot will finish any pending operations.
- MergeNeedsReboot,
-
- // Merging is complete, and needs to be acknowledged.
- MergeCompleted,
-
- // Merging failed due to an unrecoverable error.
- MergeFailed,
-
- // The update was implicitly cancelled, either by a rollback or a flash
- // operation via fastboot. This state can only be returned by WaitForMerge.
- Cancelled
-};
-std::ostream& operator<<(std::ostream& os, UpdateState state);
-
class SnapshotManager final {
using CreateLogicalPartitionParams = android::fs_mgr::CreateLogicalPartitionParams;
using IPartitionOpener = android::fs_mgr::IPartitionOpener;
@@ -433,7 +405,9 @@
// Interact with /metadata/ota/state.
UpdateState ReadUpdateState(LockedFile* file);
+ SnapshotUpdateStatus ReadSnapshotUpdateStatus(LockedFile* file);
bool WriteUpdateState(LockedFile* file, UpdateState state);
+ bool WriteSnapshotUpdateStatus(LockedFile* file, const SnapshotUpdateStatus& status);
std::string GetStateFilePath() const;
// Helpers for merging.
diff --git a/fs_mgr/libsnapshot/snapshot.cpp b/fs_mgr/libsnapshot/snapshot.cpp
index b79b65c..70a69a5 100644
--- a/fs_mgr/libsnapshot/snapshot.cpp
+++ b/fs_mgr/libsnapshot/snapshot.cpp
@@ -560,9 +560,26 @@
}
}
+ DmTargetSnapshot::Status initial_target_values = {};
+ for (const auto& snapshot : snapshots) {
+ DmTargetSnapshot::Status current_status;
+ if (!QuerySnapshotStatus(snapshot, nullptr, ¤t_status)) {
+ return false;
+ }
+ initial_target_values.sectors_allocated += current_status.sectors_allocated;
+ initial_target_values.total_sectors += current_status.total_sectors;
+ initial_target_values.metadata_sectors += current_status.metadata_sectors;
+ }
+
+ SnapshotUpdateStatus initial_status;
+ initial_status.set_state(UpdateState::Merging);
+ initial_status.set_sectors_allocated(initial_target_values.sectors_allocated);
+ initial_status.set_total_sectors(initial_target_values.total_sectors);
+ initial_status.set_metadata_sectors(initial_target_values.metadata_sectors);
+
// Point of no return - mark that we're starting a merge. From now on every
// snapshot must be a merge target.
- if (!WriteUpdateState(lock.get(), UpdateState::Merging)) {
+ if (!WriteSnapshotUpdateStatus(lock.get(), initial_status)) {
return false;
}
@@ -1643,15 +1660,7 @@
return OpenLock(LOCK_EX);
}
-UpdateState SnapshotManager::ReadUpdateState(LockedFile* lock) {
- CHECK(lock);
-
- std::string contents;
- if (!android::base::ReadFileToString(GetStateFilePath(), &contents)) {
- PLOG(ERROR) << "Read state file failed";
- return UpdateState::None;
- }
-
+static UpdateState UpdateStateFromString(const std::string& contents) {
if (contents.empty() || contents == "none") {
return UpdateState::None;
} else if (contents == "initiated") {
@@ -1694,18 +1703,54 @@
}
}
+UpdateState SnapshotManager::ReadUpdateState(LockedFile* lock) {
+ SnapshotUpdateStatus status = ReadSnapshotUpdateStatus(lock);
+ return status.state();
+}
+
+SnapshotUpdateStatus SnapshotManager::ReadSnapshotUpdateStatus(LockedFile* lock) {
+ CHECK(lock);
+
+ SnapshotUpdateStatus status = {};
+ std::string contents;
+ if (!android::base::ReadFileToString(GetStateFilePath(), &contents)) {
+ PLOG(ERROR) << "Read state file failed";
+ status.set_state(UpdateState::None);
+ return status;
+ }
+
+ if (!status.ParseFromString(contents)) {
+ LOG(WARNING) << "Unable to parse state file as SnapshotUpdateStatus, using the old format";
+
+ // Try to rollback to legacy file to support devices that are
+ // currently using the old file format.
+ // TODO(b/147409432)
+ status.set_state(UpdateStateFromString(contents));
+ }
+
+ return status;
+}
+
bool SnapshotManager::WriteUpdateState(LockedFile* lock, UpdateState state) {
+ SnapshotUpdateStatus status = {};
+ status.set_state(state);
+ return WriteSnapshotUpdateStatus(lock, status);
+}
+
+bool SnapshotManager::WriteSnapshotUpdateStatus(LockedFile* lock,
+ const SnapshotUpdateStatus& status) {
CHECK(lock);
CHECK(lock->lock_mode() == LOCK_EX);
- std::stringstream ss;
- ss << state;
- std::string contents = ss.str();
- if (contents.empty()) return false;
+ std::string contents;
+ if (!status.SerializeToString(&contents)) {
+ LOG(ERROR) << "Unable to serialize SnapshotUpdateStatus.";
+ return false;
+ }
#ifdef LIBSNAPSHOT_USE_HAL
auto merge_status = MergeStatus::UNKNOWN;
- switch (state) {
+ switch (status.state()) {
// The needs-reboot and completed cases imply that /data and /metadata
// can be safely wiped, so we don't report a merge status.
case UpdateState::None:
@@ -1724,7 +1769,7 @@
default:
// Note that Cancelled flows to here - it is never written, since
// it only communicates a transient state to the caller.
- LOG(ERROR) << "Unexpected update status: " << state;
+ LOG(ERROR) << "Unexpected update status: " << status.state();
break;
}
diff --git a/init/README.md b/init/README.md
index b8300fa..4f0a7ec 100644
--- a/init/README.md
+++ b/init/README.md
@@ -487,6 +487,25 @@
-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.
+`interface_start <name>` \
+`interface_restart <name>` \
+`interface_stop <name>`
+> Find the service that provides the interface _name_ if it exists and run the `start`, `restart`,
+or `stop` commands on it respectively. _name_ may be either a fully qualified HIDL name, in which
+case it is specified as `<interface>/<instance>`, or an AIDL name, in which case it is specified as
+`aidl/<interface>` for example `android.hardware.secure_element@1.1::ISecureElement/eSE1` or
+`aidl/aidl_lazy_test_1`.
+
+> Note that these commands only act on interfaces specified by the `interface` service option, not
+on interfaces registered at runtime.
+
+> Example usage of these commands: \
+`interface_start android.hardware.secure_element@1.1::ISecureElement/eSE1`
+will start the HIDL Service that provides the `android.hardware.secure_element@1.1` and `eSI1`
+instance. \
+`interface_start aidl/aidl_lazy_test_1` will start the AIDL service that
+provides the `aidl_lazy_test_1` interface.
+
`load_system_props`
> (This action is deprecated and no-op.)
@@ -700,6 +719,26 @@
`/sys/fs/ext4/${dev.mnt.blk.<mount_point>}/` to tune the block device
characteristics in a device agnostic manner.
+Init responds to properties that begin with `ctl.`. These properties take the format of
+`ctl.<command>` and the _value_ of the system property is used as a parameter, for example:
+`SetProperty("ctl.start", "logd")` will run the `start` command on `logd`. Note that these
+properties are only settable; they will have no value when read.
+
+`ctl.start` \
+`ctl.restart` \
+`ctl.stop`
+> These are equivalent to using the `start`, `restart`, and `stop` commands on the service specified
+by the _value_ of the property.
+
+`ctl.interface_start` \
+`ctl.interface_restart` \
+`ctl.interface_stop`
+> These are equivalent to using the `interface_start`, `interface_restart`, and `interface_stop`
+commands on the interface specified by the _value_ of the property.
+
+`ctl.sigstop_on` and `ctl.sigstop_off` will turn on or off the _sigstop_ feature for the service
+specified by the _value_ of the property. See the _Debugging init_ section below for more details
+about this feature.
Boot timing
-----------
diff --git a/init/builtins.cpp b/init/builtins.cpp
index 2a6df84..adcba3a 100644
--- a/init/builtins.cpp
+++ b/init/builtins.cpp
@@ -1119,19 +1119,28 @@
}
static Result<void> ExecVdcRebootOnFailure(const std::string& vdc_arg) {
+ bool should_reboot_into_recovery = true;
auto reboot_reason = vdc_arg + "_failed";
+ if (android::sysprop::InitProperties::userspace_reboot_in_progress().value_or(false)) {
+ should_reboot_into_recovery = false;
+ }
- auto reboot = [reboot_reason](const std::string& message) {
+ auto reboot = [reboot_reason, should_reboot_into_recovery](const std::string& message) {
// TODO (b/122850122): support this in gsi
- if (fscrypt_is_native() && !android::gsi::IsGsiRunning()) {
- LOG(ERROR) << message << ": Rebooting into recovery, reason: " << reboot_reason;
- if (auto result = reboot_into_recovery(
- {"--prompt_and_wipe_data", "--reason="s + reboot_reason});
- !result) {
- LOG(FATAL) << "Could not reboot into recovery: " << result.error();
+ if (should_reboot_into_recovery) {
+ if (fscrypt_is_native() && !android::gsi::IsGsiRunning()) {
+ LOG(ERROR) << message << ": Rebooting into recovery, reason: " << reboot_reason;
+ if (auto result = reboot_into_recovery(
+ {"--prompt_and_wipe_data", "--reason="s + reboot_reason});
+ !result) {
+ LOG(FATAL) << "Could not reboot into recovery: " << result.error();
+ }
+ } else {
+ LOG(ERROR) << "Failure (reboot suppressed): " << reboot_reason;
}
} else {
- LOG(ERROR) << "Failure (reboot suppressed): " << reboot_reason;
+ LOG(ERROR) << message << ": rebooting, reason: " << reboot_reason;
+ trigger_shutdown("reboot," + reboot_reason);
}
};
diff --git a/init/mount_namespace.cpp b/init/mount_namespace.cpp
index 93eb244..b811622 100644
--- a/init/mount_namespace.cpp
+++ b/init/mount_namespace.cpp
@@ -35,6 +35,19 @@
namespace init {
namespace {
+static bool BindMount(const std::string& source, const std::string& mount_point,
+ bool recursive = false) {
+ unsigned long mountflags = MS_BIND;
+ if (recursive) {
+ mountflags |= MS_REC;
+ }
+ if (mount(source.c_str(), mount_point.c_str(), nullptr, mountflags, nullptr) == -1) {
+ PLOG(ERROR) << "Failed to bind mount " << source;
+ return false;
+ }
+ return true;
+}
+
static bool MakeShared(const std::string& mount_point, bool recursive = false) {
unsigned long mountflags = MS_SHARED;
if (recursive) {
@@ -47,6 +60,18 @@
return true;
}
+static bool MakeSlave(const std::string& mount_point, bool recursive = false) {
+ unsigned long mountflags = MS_SLAVE;
+ if (recursive) {
+ mountflags |= MS_REC;
+ }
+ if (mount(nullptr, mount_point.c_str(), nullptr, mountflags, nullptr) == -1) {
+ PLOG(ERROR) << "Failed to change propagation type to slave";
+ return false;
+ }
+ return true;
+}
+
static bool MakePrivate(const std::string& mount_point, bool recursive = false) {
unsigned long mountflags = MS_PRIVATE;
if (recursive) {
@@ -191,6 +216,39 @@
// namespace
if (!(MakePrivate("/linkerconfig"))) return false;
+ // The two mount namespaces present challenges for scoped storage, because
+ // vold, which is responsible for most of the mounting, lives in the
+ // bootstrap mount namespace, whereas most other daemons and all apps live
+ // in the default namespace. Scoped storage has a need for a
+ // /mnt/installer view that is a slave bind mount of /mnt/user - in other
+ // words, all mounts under /mnt/user should automatically show up under
+ // /mnt/installer. However, additional mounts done under /mnt/installer
+ // should not propagate back to /mnt/user. In a single mount namespace
+ // this is easy to achieve, by simply marking the /mnt/installer a slave
+ // bind mount. Unfortunately, if /mnt/installer is only created and
+ // bind mounted after the two namespaces are created below, we end up
+ // with the following situation:
+ // /mnt/user and /mnt/installer share the same peer group in both the
+ // bootstrap and default namespaces. Marking /mnt/installer slave in either
+ // namespace means that it won't propagate events to the /mnt/installer in
+ // the other namespace, which is still something we require - vold is the
+ // one doing the mounting under /mnt/installer, and those mounts should
+ // show up in the default namespace as well.
+ //
+ // The simplest solution is to do the bind mount before the two namespaces
+ // are created: the effect is that in both namespaces, /mnt/installer is a
+ // slave to the /mnt/user mount, and at the same time /mnt/installer in the
+ // bootstrap namespace shares a peer group with /mnt/installer in the
+ // default namespace.
+ if (!mkdir_recursive("/mnt/user", 0755)) return false;
+ if (!mkdir_recursive("/mnt/installer", 0755)) return false;
+ if (!(BindMount("/mnt/user", "/mnt/installer", true))) return false;
+ // First, make /mnt/installer a slave bind mount
+ if (!(MakeSlave("/mnt/installer"))) return false;
+ // Then, make it shared again - effectively creating a new peer group, that
+ // will be inherited by new mount namespaces.
+ if (!(MakeShared("/mnt/installer"))) return false;
+
bootstrap_ns_fd.reset(OpenMountNamespace());
bootstrap_ns_id = GetMountNamespaceId();
diff --git a/init/reboot_utils.cpp b/init/reboot_utils.cpp
index dac0cf4..485188b 100644
--- a/init/reboot_utils.cpp
+++ b/init/reboot_utils.cpp
@@ -34,12 +34,16 @@
namespace init {
static std::string init_fatal_reboot_target = "bootloader";
+static bool init_fatal_panic = false;
void SetFatalRebootTarget() {
std::string cmdline;
android::base::ReadFileToString("/proc/cmdline", &cmdline);
cmdline = android::base::Trim(cmdline);
+ const char kInitFatalPanicString[] = "androidboot.init_fatal_panic=true";
+ init_fatal_panic = cmdline.find(kInitFatalPanicString) != std::string::npos;
+
const char kRebootTargetString[] = "androidboot.init_fatal_reboot_target=";
auto start_pos = cmdline.find(kRebootTargetString);
if (start_pos == std::string::npos) {
@@ -133,6 +137,9 @@
for (size_t i = 0; i < backtrace->NumFrames(); i++) {
LOG(ERROR) << backtrace->FormatFrameData(i);
}
+ if (init_fatal_panic) {
+ _exit(signal_number);
+ }
RebootSystem(ANDROID_RB_RESTART2, init_fatal_reboot_target);
}
diff --git a/init/sysprop/InitProperties.sysprop b/init/sysprop/InitProperties.sysprop
index c856358..b876dc0 100644
--- a/init/sysprop/InitProperties.sysprop
+++ b/init/sysprop/InitProperties.sysprop
@@ -29,7 +29,7 @@
prop {
api_name: "is_userspace_reboot_supported"
type: Boolean
- scope: System
+ scope: Public
access: Readonly
prop_name: "ro.init.userspace_reboot.is_supported"
integer_as_bool: true
diff --git a/libcutils/ashmem-dev.cpp b/libcutils/ashmem-dev.cpp
index 340572c..8c232f0 100644
--- a/libcutils/ashmem-dev.cpp
+++ b/libcutils/ashmem-dev.cpp
@@ -203,19 +203,23 @@
{
static const std::string ashmem_device_path = get_ashmem_device_path();
- int ret;
- struct stat st;
-
if (ashmem_device_path.empty()) {
return -1;
}
int fd = TEMP_FAILURE_RETRY(open(ashmem_device_path.c_str(), O_RDWR | O_CLOEXEC));
+
+ // fallback for APEX w/ use_vendor on Q, which would have still used /dev/ashmem
+ if (fd < 0) {
+ fd = TEMP_FAILURE_RETRY(open("/dev/ashmem", O_RDWR | O_CLOEXEC));
+ }
+
if (fd < 0) {
return fd;
}
- ret = TEMP_FAILURE_RETRY(fstat(fd, &st));
+ struct stat st;
+ int ret = TEMP_FAILURE_RETRY(fstat(fd, &st));
if (ret < 0) {
int save_errno = errno;
close(fd);
diff --git a/libcutils/include/cutils/trace.h b/libcutils/include/cutils/trace.h
index 79b4b35..e12c32c 100644
--- a/libcutils/include/cutils/trace.h
+++ b/libcutils/include/cutils/trace.h
@@ -25,7 +25,6 @@
#include <sys/cdefs.h>
#include <sys/types.h>
#include <unistd.h>
-
#include <cutils/compiler.h>
__BEGIN_DECLS
@@ -89,6 +88,12 @@
#error ATRACE_TAG must be defined to be one of the tags defined in cutils/trace.h
#endif
+// Set this to 0 to revert to the old Binder-based atrace implementation.
+// This is only here in case rollbacks do not apply cleanly.
+// TODO(fmayer): Remove this once we are confident this won't need to be
+// rolled back, no later than 2020-03-01.
+#define ATRACE_SHMEM 1
+
/**
* Opens the trace file for writing and reads the property for initial tags.
* The atrace.tags.enableflags property sets the tags to trace.
@@ -116,11 +121,15 @@
* prevent tracing within the Zygote process.
*/
void atrace_set_tracing_enabled(bool enabled);
-
/**
- * Flag indicating whether setup has been completed, initialized to 0.
- * Nonzero indicates setup has completed.
- * Note: This does NOT indicate whether or not setup was successful.
+ * If !ATRACE_SHMEM:
+ * Flag indicating whether setup has been completed, initialized to 0.
+ * Nonzero indicates setup has completed.
+ * Note: This does NOT indicate whether or not setup was successful.
+ * If ATRACE_SHMEM:
+ * This is always set to false. This forces code that uses an old version
+ * of this header to always call into atrace_setup, in which we call
+ * atrace_init unconditionally.
*/
extern atomic_bool atrace_is_ready;
@@ -143,6 +152,12 @@
* This can be explicitly run to avoid setup delay on first trace function.
*/
#define ATRACE_INIT() atrace_init()
+#define ATRACE_GET_ENABLED_TAGS() atrace_get_enabled_tags()
+
+#if ATRACE_SHMEM
+void atrace_init();
+uint64_t atrace_get_enabled_tags();
+#else
static inline void atrace_init()
{
if (CC_UNLIKELY(!atomic_load_explicit(&atrace_is_ready, memory_order_acquire))) {
@@ -155,12 +170,12 @@
* It can be used as a guard condition around more expensive trace calculations.
* Every trace function calls this, which ensures atrace_init is run.
*/
-#define ATRACE_GET_ENABLED_TAGS() atrace_get_enabled_tags()
static inline uint64_t atrace_get_enabled_tags()
{
atrace_init();
return atrace_enabled_tags;
}
+#endif
/**
* Test if a given tag is currently enabled.
diff --git a/libcutils/trace-container.cpp b/libcutils/trace-container.cpp
index d981f8f..c23d5e2 100644
--- a/libcutils/trace-container.cpp
+++ b/libcutils/trace-container.cpp
@@ -39,6 +39,11 @@
static pthread_mutex_t atrace_enabling_mutex = PTHREAD_MUTEX_INITIALIZER;
static pthread_rwlock_t atrace_container_sock_rwlock = PTHREAD_RWLOCK_INITIALIZER;
+static void atrace_seq_number_changed(uint32_t, uint32_t seq_no) {
+ pthread_once(&atrace_once_control, atrace_init_once);
+ atomic_store_explicit(&last_sequence_number, seq_no, memory_order_relaxed);
+}
+
static bool atrace_init_container_sock()
{
pthread_rwlock_wrlock(&atrace_container_sock_rwlock);
diff --git a/libcutils/trace-dev.cpp b/libcutils/trace-dev.cpp
index bff16c1..2ee39d3 100644
--- a/libcutils/trace-dev.cpp
+++ b/libcutils/trace-dev.cpp
@@ -37,12 +37,39 @@
} else {
atrace_enabled_tags = atrace_get_property();
}
+#if !ATRACE_SHMEM
atomic_store_explicit(&atrace_is_ready, true, memory_order_release);
+#endif
+}
+
+static void atrace_seq_number_changed(uint32_t prev_seq_no, uint32_t seq_no) {
+ if (!atomic_load_explicit(&atrace_is_enabled, memory_order_acquire)) {
+ return;
+ }
+
+ // Someone raced us.
+ if (!atomic_compare_exchange_strong(&last_sequence_number, &prev_seq_no, seq_no)) {
+ return;
+ }
+
+ if (CC_UNLIKELY(prev_seq_no == kSeqNoNotInit)) {
+#if defined(__BIONIC__)
+ const prop_info* new_pi = __system_property_find("debug.atrace.tags.enableflags");
+ if (new_pi) atrace_property_info = new_pi;
+#endif
+ pthread_once(&atrace_once_control, atrace_init_once);
+ }
+
+ atrace_update_tags();
}
void atrace_setup()
{
+#if ATRACE_SHMEM
+ atrace_init();
+#else
pthread_once(&atrace_once_control, atrace_init_once);
+#endif
}
void atrace_begin_body(const char* name)
diff --git a/libcutils/trace-dev.inc b/libcutils/trace-dev.inc
index e3da77b..a57a4c5 100644
--- a/libcutils/trace-dev.inc
+++ b/libcutils/trace-dev.inc
@@ -34,6 +34,11 @@
#include <log/log.h>
#include <log/log_properties.h>
+#if defined(__BIONIC__)
+#define _REALLY_INCLUDE_SYS__SYSTEM_PROPERTIES_H_
+#include <sys/_system_properties.h>
+#endif
+
/**
* Maximum size of a message that can be logged to the trace buffer.
* Note this message includes a tag, the pid, and the string given as the name.
@@ -41,12 +46,57 @@
*/
#define ATRACE_MESSAGE_LENGTH 1024
-atomic_bool atrace_is_ready = ATOMIC_VAR_INIT(false);
-int atrace_marker_fd = -1;
-uint64_t atrace_enabled_tags = ATRACE_TAG_NOT_READY;
-static bool atrace_is_debuggable = false;
-static atomic_bool atrace_is_enabled = ATOMIC_VAR_INIT(true);
-static pthread_mutex_t atrace_tags_mutex = PTHREAD_MUTEX_INITIALIZER;
+constexpr uint32_t kSeqNoNotInit = static_cast<uint32_t>(-1);
+
+atomic_bool atrace_is_ready = ATOMIC_VAR_INIT(false);
+int atrace_marker_fd = -1;
+uint64_t atrace_enabled_tags = ATRACE_TAG_NOT_READY;
+static bool atrace_is_debuggable = false;
+static atomic_bool atrace_is_enabled = ATOMIC_VAR_INIT(true);
+static pthread_mutex_t atrace_tags_mutex = PTHREAD_MUTEX_INITIALIZER;
+
+/**
+ * Sequence number of debug.atrace.tags.enableflags the last time the enabled
+ * tags were reloaded.
+ **/
+static _Atomic(uint32_t) last_sequence_number = ATOMIC_VAR_INIT(kSeqNoNotInit);
+
+#if defined(__BIONIC__)
+// All zero prop_info that has a sequence number of 0. This is easier than
+// depending on implementation details of the property implementation.
+//
+// prop_info is static_assert-ed to be 96 bytes, which cannot change due to
+// ABI compatibility.
+alignas(uint64_t) static char empty_pi[96];
+static const prop_info* atrace_property_info = reinterpret_cast<const prop_info*>(empty_pi);
+#endif
+
+#if ATRACE_SHMEM
+
+/**
+ * This is called when the sequence number of debug.atrace.tags.enableflags
+ * changes and we need to reload the enabled tags.
+ **/
+static void atrace_seq_number_changed(uint32_t prev_seq_no, uint32_t seq_no);
+
+void atrace_init() {
+#if defined(__BIONIC__)
+ uint32_t seq_no = __system_property_serial(atrace_property_info); // Acquire semantics.
+#else
+ uint32_t seq_no = 0;
+#endif
+ uint32_t prev_seq_no = atomic_load_explicit(&last_sequence_number, memory_order_relaxed);
+ if (CC_UNLIKELY(seq_no != prev_seq_no)) {
+ atrace_seq_number_changed(prev_seq_no, seq_no);
+ }
+}
+
+uint64_t atrace_get_enabled_tags()
+{
+ atrace_init();
+ return atrace_enabled_tags;
+}
+#endif
// Set whether this process is debuggable, which determines whether
// application-level tracing is allowed when the ro.debuggable system property
@@ -136,7 +186,7 @@
void atrace_update_tags()
{
uint64_t tags;
- if (CC_UNLIKELY(atomic_load_explicit(&atrace_is_ready, memory_order_acquire))) {
+ if (ATRACE_SHMEM || CC_UNLIKELY(atomic_load_explicit(&atrace_is_ready, memory_order_acquire))) {
if (atomic_load_explicit(&atrace_is_enabled, memory_order_acquire)) {
tags = atrace_get_property();
pthread_mutex_lock(&atrace_tags_mutex);
diff --git a/libcutils/trace-host.cpp b/libcutils/trace-host.cpp
index d47cc18..c21d0ee 100644
--- a/libcutils/trace-host.cpp
+++ b/libcutils/trace-host.cpp
@@ -30,3 +30,10 @@
void atrace_async_end_body(const char* /*name*/, int32_t /*cookie*/) {}
void atrace_int_body(const char* /*name*/, int32_t /*value*/) {}
void atrace_int64_body(const char* /*name*/, int64_t /*value*/) {}
+#if ATRACE_SHMEM
+void atrace_init() {}
+uint64_t atrace_get_enabled_tags()
+{
+ return ATRACE_TAG_NOT_READY;
+}
+#endif
diff --git a/liblog/event_tag_map.cpp b/liblog/event_tag_map.cpp
index 2886289..51c5e60 100644
--- a/liblog/event_tag_map.cpp
+++ b/liblog/event_tag_map.cpp
@@ -36,7 +36,6 @@
#include <utils/FastStrcmp.h>
#include <utils/RWLock.h>
-#include "log_portability.h"
#include "logd_reader.h"
#define OUT_TAG "EventTagMap"
diff --git a/liblog/fake_log_device.cpp b/liblog/fake_log_device.cpp
index 2ec6393..2582cea 100644
--- a/liblog/fake_log_device.cpp
+++ b/liblog/fake_log_device.cpp
@@ -36,7 +36,6 @@
#include <log/log_id.h>
#include <log/logprint.h>
-#include "log_portability.h"
#include "logger.h"
#define kMaxTagLen 16 /* from the long-dead utils/Log.cpp */
@@ -49,14 +48,6 @@
#define TRACE(...) ((void)0)
#endif
-static void FakeClose();
-static int FakeWrite(log_id_t log_id, struct timespec* ts, struct iovec* vec, size_t nr);
-
-struct android_log_transport_write fakeLoggerWrite = {
- .close = FakeClose,
- .write = FakeWrite,
-};
-
typedef struct LogState {
bool initialized = false;
/* global minimum priority */
@@ -453,7 +444,7 @@
* tag (N bytes -- null-terminated ASCII string)
* message (N bytes -- null-terminated ASCII string)
*/
-static int FakeWrite(log_id_t log_id, struct timespec*, struct iovec* vector, size_t count) {
+int FakeWrite(log_id_t log_id, struct timespec*, struct iovec* vector, size_t count) {
/* Make sure that no-one frees the LogState while we're using it.
* Also guarantees that only one thread is in showLog() at a given
* time (if it matters).
@@ -519,7 +510,7 @@
* call is in the exit handler. Logging can continue in the exit handler to
* help debug HOST tools ...
*/
-static void FakeClose() {
+void FakeClose() {
auto lock = std::lock_guard{*fake_log_mutex};
memset(&log_state, 0, sizeof(log_state));
diff --git a/liblog/fake_log_device.h b/liblog/fake_log_device.h
index bd2256c..53f1b41 100644
--- a/liblog/fake_log_device.h
+++ b/liblog/fake_log_device.h
@@ -16,18 +16,15 @@
#pragma once
+#include <sys/cdefs.h>
#include <sys/types.h>
-#include "log_portability.h"
-#include "uio.h"
-
-struct iovec;
+#include <android/log.h>
__BEGIN_DECLS
-int fakeLogOpen(const char* pathName);
-int fakeLogClose(int fd);
-ssize_t fakeLogWritev(int fd, const struct iovec* vector, int count);
+void FakeClose();
+int FakeWrite(log_id_t log_id, struct timespec* ts, struct iovec* vec, size_t nr);
int __android_log_is_loggable(int prio, const char*, int def);
int __android_log_is_loggable_len(int prio, const char*, size_t, int def);
diff --git a/liblog/log_event_list.cpp b/liblog/log_event_list.cpp
index e9f4a32..cb70d48 100644
--- a/liblog/log_event_list.cpp
+++ b/liblog/log_event_list.cpp
@@ -25,8 +25,6 @@
#include <log/log_event_list.h>
#include <private/android_logger.h>
-#include "log_portability.h"
-
#define MAX_EVENT_PAYLOAD (LOGGER_ENTRY_MAX_PAYLOAD - sizeof(int32_t))
enum ReadWriteFlag {
diff --git a/liblog/log_event_write.cpp b/liblog/log_event_write.cpp
index d04ba90..39afd0c 100644
--- a/liblog/log_event_write.cpp
+++ b/liblog/log_event_write.cpp
@@ -20,8 +20,6 @@
#include <log/log.h>
#include <log/log_event_list.h>
-#include "log_portability.h"
-
#define MAX_SUBTAG_LEN 32
int __android_log_error_write(int tag, const char* subTag, int32_t uid, const char* data,
diff --git a/liblog/log_portability.h b/liblog/log_portability.h
deleted file mode 100644
index b7279d1..0000000
--- a/liblog/log_portability.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright (C) 2016 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#pragma once
-
-#include <sys/cdefs.h>
-#include <unistd.h>
-
-/* possible missing definitions in sys/cdefs.h */
-
-/* DECLS */
-#ifndef __BEGIN_DECLS
-#if defined(__cplusplus)
-#define __BEGIN_DECLS extern "C" {
-#define __END_DECLS }
-#else
-#define __BEGIN_DECLS
-#define __END_DECLS
-#endif
-#endif
-
-/* possible missing definitions in unistd.h */
-
-#ifndef TEMP_FAILURE_RETRY
-/* Used to retry syscalls that can return EINTR. */
-#define TEMP_FAILURE_RETRY(exp) \
- ({ \
- __typeof__(exp) _rc; \
- do { \
- _rc = (exp); \
- } while (_rc == -1 && errno == EINTR); \
- _rc; \
- })
-#endif
diff --git a/liblog/log_time.cpp b/liblog/log_time.cpp
index 3ae250f..3fbe1cb 100644
--- a/liblog/log_time.cpp
+++ b/liblog/log_time.cpp
@@ -21,8 +21,6 @@
#include <private/android_logger.h>
-#include "log_portability.h"
-
const char log_time::default_format[] = "%m-%d %H:%M:%S.%q";
const timespec log_time::EPOCH = {0, 0};
diff --git a/liblog/logd_reader.cpp b/liblog/logd_reader.cpp
index 6865c14..82ed6b2 100644
--- a/liblog/logd_reader.cpp
+++ b/liblog/logd_reader.cpp
@@ -35,8 +35,6 @@
#include <string>
-#include <cutils/sockets.h>
-#include <private/android_filesystem_config.h>
#include <private/android_logger.h>
#include "logger.h"
diff --git a/liblog/logd_reader.h b/liblog/logd_reader.h
index 2d032fa..68eef02 100644
--- a/liblog/logd_reader.h
+++ b/liblog/logd_reader.h
@@ -16,10 +16,10 @@
#pragma once
+#include <sys/cdefs.h>
#include <unistd.h>
#include "log/log_read.h"
-#include "log_portability.h"
__BEGIN_DECLS
diff --git a/liblog/logd_writer.cpp b/liblog/logd_writer.cpp
index 3c6eb69..67376f4 100644
--- a/liblog/logd_writer.cpp
+++ b/liblog/logd_writer.cpp
@@ -14,6 +14,8 @@
* limitations under the License.
*/
+#include "logd_writer.h"
+
#include <errno.h>
#include <fcntl.h>
#include <inttypes.h>
@@ -32,23 +34,13 @@
#include <shared_mutex>
-#include <cutils/sockets.h>
#include <private/android_filesystem_config.h>
#include <private/android_logger.h>
-#include "log_portability.h"
#include "logger.h"
#include "rwlock.h"
#include "uio.h"
-static int LogdWrite(log_id_t logId, struct timespec* ts, struct iovec* vec, size_t nr);
-static void LogdClose();
-
-struct android_log_transport_write logdLoggerWrite = {
- .close = LogdClose,
- .write = LogdWrite,
-};
-
static int logd_socket;
static RwLock logd_socket_lock;
@@ -90,7 +82,7 @@
OpenSocketLocked();
}
-static void LogdClose() {
+void LogdClose() {
auto lock = std::unique_lock{logd_socket_lock};
if (logd_socket > 0) {
close(logd_socket);
@@ -98,7 +90,7 @@
logd_socket = 0;
}
-static int LogdWrite(log_id_t logId, struct timespec* ts, struct iovec* vec, size_t nr) {
+int LogdWrite(log_id_t logId, struct timespec* ts, struct iovec* vec, size_t nr) {
ssize_t ret;
static const unsigned headerLength = 1;
struct iovec newVec[nr + headerLength];
@@ -119,7 +111,7 @@
}
/* logd, after initialization and priv drop */
- if (__android_log_uid() == AID_LOGD) {
+ if (getuid() == AID_LOGD) {
/*
* ignore log messages we send to ourself (logd).
* Such log messages are often generated by libraries we depend on
diff --git a/liblog/logd_writer.h b/liblog/logd_writer.h
new file mode 100644
index 0000000..41197b5
--- /dev/null
+++ b/liblog/logd_writer.h
@@ -0,0 +1,24 @@
+/*
+ * Copyright (C) 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#pragma once
+
+#include <stddef.h>
+
+#include <android/log.h>
+
+int LogdWrite(log_id_t logId, struct timespec* ts, struct iovec* vec, size_t nr);
+void LogdClose();
diff --git a/liblog/logger.h b/liblog/logger.h
index 40d5fe5..ddff19d 100644
--- a/liblog/logger.h
+++ b/liblog/logger.h
@@ -17,22 +17,14 @@
#pragma once
#include <stdatomic.h>
+#include <sys/cdefs.h>
-#include <cutils/list.h>
#include <log/log.h>
-#include "log_portability.h"
#include "uio.h"
__BEGIN_DECLS
-struct android_log_transport_write {
- void (*close)(); /* free up resources */
- /* write log to transport, returns number of bytes propagated, or -errno */
- int (*write)(log_id_t logId, struct timespec* ts, struct iovec* vec,
- size_t nr);
-};
-
struct logger_list {
atomic_int fd;
int mode;
@@ -56,18 +48,4 @@
return reinterpret_cast<uintptr_t>(logger) & LOGGER_LOGD;
}
-/* OS specific dribs and drabs */
-
-#if defined(_WIN32)
-#include <private/android_filesystem_config.h>
-typedef uint32_t uid_t;
-static inline uid_t __android_log_uid() {
- return AID_SYSTEM;
-}
-#else
-static inline uid_t __android_log_uid() {
- return getuid();
-}
-#endif
-
__END_DECLS
diff --git a/liblog/logger_name.cpp b/liblog/logger_name.cpp
index ece0550..7d676f4 100644
--- a/liblog/logger_name.cpp
+++ b/liblog/logger_name.cpp
@@ -19,8 +19,6 @@
#include <log/log.h>
-#include "log_portability.h"
-
/* In the future, we would like to make this list extensible */
static const char* LOG_NAME[LOG_ID_MAX] = {
/* clang-format off */
diff --git a/liblog/logger_read.cpp b/liblog/logger_read.cpp
index 0d383ff..e0598de 100644
--- a/liblog/logger_read.cpp
+++ b/liblog/logger_read.cpp
@@ -27,10 +27,7 @@
#include <unistd.h>
#include <android/log.h>
-#include <cutils/list.h>
-#include <private/android_filesystem_config.h>
-#include "log_portability.h"
#include "logd_reader.h"
#include "logger.h"
#include "pmsg_reader.h"
diff --git a/liblog/logger_write.cpp b/liblog/logger_write.cpp
index d38b402..d6ef951 100644
--- a/liblog/logger_write.cpp
+++ b/liblog/logger_write.cpp
@@ -15,7 +15,6 @@
*/
#include <errno.h>
-#include <stdatomic.h>
#include <stdlib.h>
#include <string.h>
#include <sys/time.h>
@@ -24,31 +23,25 @@
#include <android/set_abort_message.h>
#endif
+#include <android-base/macros.h>
#include <private/android_filesystem_config.h>
#include <private/android_logger.h>
-#include "log_portability.h"
#include "logger.h"
#include "uio.h"
-#define LOG_BUF_SIZE 1024
-
#if (FAKE_LOG_DEVICE == 0)
-extern struct android_log_transport_write logdLoggerWrite;
-extern struct android_log_transport_write pmsgLoggerWrite;
-
-android_log_transport_write* android_log_write = &logdLoggerWrite;
-android_log_transport_write* android_log_persist_write = &pmsgLoggerWrite;
+#include "logd_writer.h"
+#include "pmsg_writer.h"
#else
-extern android_log_transport_write fakeLoggerWrite;
-
-android_log_transport_write* android_log_write = &fakeLoggerWrite;
-android_log_transport_write* android_log_persist_write = nullptr;
+#include "fake_log_device.h"
#endif
+#define LOG_BUF_SIZE 1024
+
#if defined(__ANDROID__)
static int check_log_uid_permissions() {
- uid_t uid = __android_log_uid();
+ uid_t uid = getuid();
/* Matches clientHasLogCredentials() in logd */
if ((uid != AID_SYSTEM) && (uid != AID_ROOT) && (uid != AID_LOG)) {
@@ -92,14 +85,12 @@
* Release any logger resources. A new log write will immediately re-acquire.
*/
void __android_log_close() {
- if (android_log_write != nullptr) {
- android_log_write->close();
- }
-
- if (android_log_persist_write != nullptr) {
- android_log_persist_write->close();
- }
-
+#if (FAKE_LOG_DEVICE == 0)
+ LogdClose();
+ PmsgClose();
+#else
+ FakeClose();
+#endif
}
static int write_to_log(log_id_t log_id, struct iovec* vec, size_t nr) {
@@ -158,17 +149,12 @@
ret = 0;
- if (android_log_write != nullptr) {
- ssize_t retval;
- retval = android_log_write->write(log_id, &ts, vec, nr);
- if (ret >= 0) {
- ret = retval;
- }
- }
-
- if (android_log_persist_write != nullptr) {
- android_log_persist_write->write(log_id, &ts, vec, nr);
- }
+#if (FAKE_LOG_DEVICE == 0)
+ ret = LogdWrite(log_id, &ts, vec, nr);
+ PmsgWrite(log_id, &ts, vec, nr);
+#else
+ ret = FakeWrite(log_id, &ts, vec, nr);
+#endif
errno = save_errno;
return ret;
diff --git a/liblog/logprint.cpp b/liblog/logprint.cpp
index 4b61828..0745a1e 100644
--- a/liblog/logprint.cpp
+++ b/liblog/logprint.cpp
@@ -40,8 +40,6 @@
#include <log/logprint.h>
#include <private/android_logger.h>
-#include "log_portability.h"
-
#define MS_PER_NSEC 1000000
#define US_PER_NSEC 1000
diff --git a/liblog/pmsg_reader.cpp b/liblog/pmsg_reader.cpp
index 9390fec..64a92b7 100644
--- a/liblog/pmsg_reader.cpp
+++ b/liblog/pmsg_reader.cpp
@@ -23,7 +23,7 @@
#include <string.h>
#include <sys/types.h>
-#include <private/android_filesystem_config.h>
+#include <cutils/list.h>
#include <private/android_logger.h>
#include "logger.h"
diff --git a/liblog/pmsg_reader.h b/liblog/pmsg_reader.h
index 53746d8..b784f9f 100644
--- a/liblog/pmsg_reader.h
+++ b/liblog/pmsg_reader.h
@@ -16,10 +16,10 @@
#pragma once
+#include <sys/cdefs.h>
#include <unistd.h>
#include "log/log_read.h"
-#include "log_portability.h"
__BEGIN_DECLS
diff --git a/liblog/pmsg_writer.cpp b/liblog/pmsg_writer.cpp
index 4f45780..06e5e04 100644
--- a/liblog/pmsg_writer.cpp
+++ b/liblog/pmsg_writer.cpp
@@ -14,9 +14,7 @@
* limitations under the License.
*/
-/*
- * pmsg write handler
- */
+#include "pmsg_writer.h"
#include <errno.h>
#include <fcntl.h>
@@ -28,22 +26,12 @@
#include <shared_mutex>
#include <log/log_properties.h>
-#include <private/android_filesystem_config.h>
#include <private/android_logger.h>
-#include "log_portability.h"
#include "logger.h"
#include "rwlock.h"
#include "uio.h"
-static void PmsgClose();
-static int PmsgWrite(log_id_t logId, struct timespec* ts, struct iovec* vec, size_t nr);
-
-struct android_log_transport_write pmsgLoggerWrite = {
- .close = PmsgClose,
- .write = PmsgWrite,
-};
-
static int pmsg_fd;
static RwLock pmsg_fd_lock;
@@ -57,7 +45,7 @@
pmsg_fd = TEMP_FAILURE_RETRY(open("/dev/pmsg0", O_WRONLY | O_CLOEXEC));
}
-static void PmsgClose() {
+void PmsgClose() {
auto lock = std::unique_lock{pmsg_fd_lock};
if (pmsg_fd > 0) {
close(pmsg_fd);
@@ -65,7 +53,7 @@
pmsg_fd = 0;
}
-static int PmsgWrite(log_id_t logId, struct timespec* ts, struct iovec* vec, size_t nr) {
+int PmsgWrite(log_id_t logId, struct timespec* ts, struct iovec* vec, size_t nr) {
static const unsigned headerLength = 2;
struct iovec newVec[nr + headerLength];
android_log_header_t header;
@@ -123,7 +111,7 @@
pmsgHeader.magic = LOGGER_MAGIC;
pmsgHeader.len = sizeof(pmsgHeader) + sizeof(header);
- pmsgHeader.uid = __android_log_uid();
+ pmsgHeader.uid = getuid();
pmsgHeader.pid = getpid();
header.id = logId;
diff --git a/liblog/pmsg_writer.h b/liblog/pmsg_writer.h
new file mode 100644
index 0000000..d5e1a1c
--- /dev/null
+++ b/liblog/pmsg_writer.h
@@ -0,0 +1,24 @@
+/*
+ * Copyright (C) 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#pragma once
+
+#include <stddef.h>
+
+#include <android/log.h>
+
+int PmsgWrite(log_id_t logId, struct timespec* ts, struct iovec* vec, size_t nr);
+void PmsgClose();
diff --git a/liblog/properties.cpp b/liblog/properties.cpp
index 2e0a8c9..2b2327c 100644
--- a/liblog/properties.cpp
+++ b/liblog/properties.cpp
@@ -26,8 +26,6 @@
#include <private/android_logger.h>
-#include "log_portability.h"
-
static pthread_mutex_t lock_loggable = PTHREAD_MUTEX_INITIALIZER;
static int lock() {
diff --git a/libvndksupport/Android.bp b/libvndksupport/Android.bp
index f4544a1..b92c76c 100644
--- a/libvndksupport/Android.bp
+++ b/libvndksupport/Android.bp
@@ -1,5 +1,3 @@
-subdirs = ["tests"]
-
cc_library {
name: "libvndksupport",
native_bridge_supported: true,
diff --git a/property_service/Android.bp b/property_service/Android.bp
deleted file mode 100644
index b44c296..0000000
--- a/property_service/Android.bp
+++ /dev/null
@@ -1 +0,0 @@
-subdirs = ["*"]
diff --git a/rootdir/init.rc b/rootdir/init.rc
index 7a3339d..00053ad 100644
--- a/rootdir/init.rc
+++ b/rootdir/init.rc
@@ -42,6 +42,10 @@
mkdir /linkerconfig/bootstrap 0755
mkdir /linkerconfig/default 0755
+ # Disable dm-verity hash prefetching, since it doesn't help performance
+ # Read more in b/136247322
+ write /sys/module/dm_verity/parameters/prefetch_cluster 0
+
# Generate ld.config.txt for early executed processes
exec -- /system/bin/linkerconfig --target /linkerconfig/bootstrap
chmod 644 /linkerconfig/bootstrap/ld.config.txt
@@ -584,7 +588,7 @@
# profile file layout
mkdir /data/misc/profiles 0771 system system
mkdir /data/misc/profiles/cur 0771 system system
- mkdir /data/misc/profiles/ref 0771 system system
+ mkdir /data/misc/profiles/ref 0770 system system
mkdir /data/misc/profman 0770 system shell
mkdir /data/misc/gcov 0770 root root
mkdir /data/misc/installd 0700 root root
@@ -691,6 +695,10 @@
mount none /data/user /data_mirror/data_ce/null bind rec
mount none /data/user_de /data_mirror/data_de/null bind rec
+ # Create mirror directory for jit profiles
+ mkdir /data_mirror/cur_profiles 0700 root root
+ mount none /data/misc/profiles/cur /data_mirror/cur_profiles bind rec
+
mkdir /data/cache 0770 system cache encryption=Require
mkdir /data/cache/recovery 0770 system cache
mkdir /data/cache/backup_stage 0700 system system
@@ -701,7 +709,7 @@
mkdir /data/rollback-observer 0700 system system encryption=DeleteIfNecessary
# Create root dir for Incremental Service
- mkdir /data/incremental 0770 system system encryption=None
+ mkdir /data/incremental 0771 system system encryption=Require
# Wait for apexd to finish activating APEXes before starting more processes.
wait_for_prop apexd.status ready
diff --git a/storaged/main.cpp b/storaged/main.cpp
index 3817fb5..e35bd6f 100644
--- a/storaged/main.cpp
+++ b/storaged/main.cpp
@@ -51,7 +51,7 @@
storaged_sp->init();
storaged_sp->report_storage_info();
- LOG_TO(SYSTEM, INFO) << "storaged: Start";
+ LOG(INFO) << "storaged: Start";
for (;;) {
storaged_sp->event_checked();
@@ -76,6 +76,8 @@
bool flag_dump_perf = false;
int opt;
+ android::base::InitLogging(argv, android::base::LogdLogger(android::base::SYSTEM));
+
for (;;) {
int opt_idx = 0;
static struct option long_options[] = {
@@ -124,13 +126,13 @@
pthread_t storaged_main_thread;
errno = pthread_create(&storaged_main_thread, NULL, storaged_main, NULL);
if (errno != 0) {
- PLOG_TO(SYSTEM, ERROR) << "Failed to create main thread";
+ PLOG(ERROR) << "Failed to create main thread";
return -1;
}
if (StoragedService::start() != android::OK ||
StoragedPrivateService::start() != android::OK) {
- PLOG_TO(SYSTEM, ERROR) << "Failed to start storaged service";
+ PLOG(ERROR) << "Failed to start storaged service";
return -1;
}
diff --git a/storaged/storaged.cpp b/storaged/storaged.cpp
index 1d934a2..573b8c5 100644
--- a/storaged/storaged.cpp
+++ b/storaged/storaged.cpp
@@ -97,25 +97,23 @@
health = get_health_service();
if (health == NULL) {
- LOG_TO(SYSTEM, WARNING) << "health: failed to find IHealth service";
+ LOG(WARNING) << "health: failed to find IHealth service";
return;
}
BatteryStatus status = BatteryStatus::UNKNOWN;
auto ret = health->getChargeStatus([&](Result r, BatteryStatus v) {
if (r != Result::SUCCESS) {
- LOG_TO(SYSTEM, WARNING)
- << "health: cannot get battery status " << toString(r);
+ LOG(WARNING) << "health: cannot get battery status " << toString(r);
return;
}
if (v == BatteryStatus::UNKNOWN) {
- LOG_TO(SYSTEM, WARNING) << "health: invalid battery status";
+ LOG(WARNING) << "health: invalid battery status";
}
status = v;
});
if (!ret.isOk()) {
- LOG_TO(SYSTEM, WARNING) << "health: get charge status transaction error "
- << ret.description();
+ LOG(WARNING) << "health: get charge status transaction error " << ret.description();
}
mUidm.init(is_charger_on(status));
@@ -126,11 +124,11 @@
void storaged_t::serviceDied(uint64_t cookie, const wp<::android::hidl::base::V1_0::IBase>& who) {
if (health != NULL && interfacesEqual(health, who.promote())) {
- LOG_TO(SYSTEM, ERROR) << "health service died, exiting";
+ LOG(ERROR) << "health service died, exiting";
android::hardware::IPCThreadState::self()->stopProcess();
exit(1);
} else {
- LOG_TO(SYSTEM, ERROR) << "unknown service died";
+ LOG(ERROR) << "unknown service died";
}
}
@@ -192,7 +190,7 @@
reinterpret_cast<const Bytef*>(uid_io_usage.SerializeAsString().c_str()),
uid_io_usage.ByteSize());
if (proto.crc() != computed_crc) {
- LOG_TO(SYSTEM, WARNING) << "CRC mismatch in " << proto_file;
+ LOG(WARNING) << "CRC mismatch in " << proto_file;
return;
}
@@ -228,8 +226,7 @@
char* data = nullptr;
if (posix_memalign(reinterpret_cast<void**>(&data),
pagesize, proto->ByteSize())) {
- PLOG_TO(SYSTEM, ERROR) << "Faied to alloc aligned buffer (size: "
- << proto->ByteSize() << ")";
+ PLOG(ERROR) << "Faied to alloc aligned buffer (size: " << proto->ByteSize() << ")";
return data;
}
@@ -246,7 +243,7 @@
(user_id == USER_SYSTEM ? O_DIRECT : 0),
S_IRUSR | S_IWUSR)));
if (fd == -1) {
- PLOG_TO(SYSTEM, ERROR) << "Faied to open tmp file: " << tmp_file;
+ PLOG(ERROR) << "Faied to open tmp file: " << tmp_file;
return;
}
@@ -261,7 +258,7 @@
start = steady_clock::now();
ret = write(fd, data, MIN(benchmark_unit_size, size));
if (ret <= 0) {
- PLOG_TO(SYSTEM, ERROR) << "Faied to write tmp file: " << tmp_file;
+ PLOG(ERROR) << "Faied to write tmp file: " << tmp_file;
return;
}
end = steady_clock::now();
@@ -284,7 +281,7 @@
}
} else {
if (!WriteFully(fd, data, size)) {
- PLOG_TO(SYSTEM, ERROR) << "Faied to write tmp file: " << tmp_file;
+ PLOG(ERROR) << "Faied to write tmp file: " << tmp_file;
return;
}
}
@@ -343,22 +340,21 @@
if (mConfig.event_time_check_usec &&
clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &start_ts) < 0) {
check_time = false;
- PLOG_TO(SYSTEM, ERROR) << "clock_gettime() failed";
+ PLOG(ERROR) << "clock_gettime() failed";
}
event();
if (mConfig.event_time_check_usec && check_time) {
if (clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &end_ts) < 0) {
- PLOG_TO(SYSTEM, ERROR) << "clock_gettime() failed";
+ PLOG(ERROR) << "clock_gettime() failed";
return;
}
int64_t cost = (end_ts.tv_sec - start_ts.tv_sec) * SEC_TO_USEC +
(end_ts.tv_nsec - start_ts.tv_nsec) / USEC_TO_NSEC;
if (cost > mConfig.event_time_check_usec) {
- LOG_TO(SYSTEM, ERROR)
- << "event loop spent " << cost << " usec, threshold "
- << mConfig.event_time_check_usec << " usec";
+ LOG(ERROR) << "event loop spent " << cost << " usec, threshold "
+ << mConfig.event_time_check_usec << " usec";
}
}
}
diff --git a/storaged/storaged_diskstats.cpp b/storaged/storaged_diskstats.cpp
index 8b5001d..52bd4e0 100644
--- a/storaged/storaged_diskstats.cpp
+++ b/storaged/storaged_diskstats.cpp
@@ -41,8 +41,8 @@
// skip if the input structure are all zeros
if (perf == NULL || perf->is_zero()) return;
- LOG_TO(SYSTEM, INFO) << "disk_perf " << type
- << " rd: " << perf->read_perf << " kbps, " << perf->read_ios << " iops"
+ LOG(INFO) << "disk_perf " << type << " rd: " << perf->read_perf << " kbps, " << perf->read_ios
+ << " iops"
<< " wr: " << perf->write_perf << " kbps, " << perf->write_ios << " iops"
<< " q: " << perf->queue;
}
@@ -71,7 +71,7 @@
// when system is running.
int ret = clock_gettime(CLOCK_MONOTONIC, ts);
if (ret < 0) {
- PLOG_TO(SYSTEM, ERROR) << "clock_gettime() failed";
+ PLOG(ERROR) << "clock_gettime() failed";
return false;
}
return true;
@@ -93,7 +93,7 @@
std::string buffer;
if (!android::base::ReadFileToString(disk_stats_path, &buffer)) {
- PLOG_TO(SYSTEM, ERROR) << disk_stats_path << ": ReadFileToString failed.";
+ PLOG(ERROR) << disk_stats_path << ": ReadFileToString failed.";
return false;
}
@@ -130,12 +130,12 @@
bool success = false;
auto ret = service->getDiskStats([&success, stats](auto result, const auto& halStats) {
if (result == Result::NOT_SUPPORTED) {
- LOG_TO(SYSTEM, DEBUG) << "getDiskStats is not supported on health HAL.";
+ LOG(DEBUG) << "getDiskStats is not supported on health HAL.";
return;
}
if (result != Result::SUCCESS || halStats.size() == 0) {
- LOG_TO(SYSTEM, ERROR) << "getDiskStats failed with result " << toString(result)
- << " and size " << halStats.size();
+ LOG(ERROR) << "getDiskStats failed with result " << toString(result) << " and size "
+ << halStats.size();
return;
}
@@ -144,7 +144,7 @@
});
if (!ret.isOk()) {
- LOG_TO(SYSTEM, ERROR) << "getDiskStats failed with " << ret.description();
+ LOG(ERROR) << "getDiskStats failed with " << ret.description();
return false;
}
@@ -199,9 +199,9 @@
void add_disk_stats(struct disk_stats* src, struct disk_stats* dst)
{
if (dst->end_time != 0 && dst->end_time != src->start_time) {
- LOG_TO(SYSTEM, WARNING) << "Two dis-continuous periods of diskstats"
- << " are added. dst end with " << dst->end_time
- << ", src start with " << src->start_time;
+ LOG(WARNING) << "Two dis-continuous periods of diskstats"
+ << " are added. dst end with " << dst->end_time << ", src start with "
+ << src->start_time;
}
*dst += *src;
diff --git a/storaged/storaged_info.cpp b/storaged/storaged_info.cpp
index 6668cf3..bb21829 100644
--- a/storaged/storaged_info.cpp
+++ b/storaged/storaged_info.cpp
@@ -76,7 +76,7 @@
if (!perf_history.has_day_start_sec() ||
perf_history.daily_perf_size() > (int)daily_perf.size() ||
perf_history.weekly_perf_size() > (int)weekly_perf.size()) {
- LOG_TO(SYSTEM, ERROR) << "Invalid IOPerfHistory proto";
+ LOG(ERROR) << "Invalid IOPerfHistory proto";
return;
}
@@ -114,7 +114,7 @@
{
struct statvfs buf;
if (statvfs(userdata_path.c_str(), &buf) != 0) {
- PLOG_TO(SYSTEM, WARNING) << "Failed to get userdata info";
+ PLOG(WARNING) << "Failed to get userdata info";
return;
}
@@ -328,12 +328,12 @@
void health_storage_info_t::report() {
auto ret = mHealth->getStorageInfo([this](auto result, const auto& halInfos) {
if (result == Result::NOT_SUPPORTED) {
- LOG_TO(SYSTEM, DEBUG) << "getStorageInfo is not supported on health HAL.";
+ LOG(DEBUG) << "getStorageInfo is not supported on health HAL.";
return;
}
if (result != Result::SUCCESS || halInfos.size() == 0) {
- LOG_TO(SYSTEM, ERROR) << "getStorageInfo failed with result " << toString(result)
- << " and size " << halInfos.size();
+ LOG(ERROR) << "getStorageInfo failed with result " << toString(result) << " and size "
+ << halInfos.size();
return;
}
set_values_from_hal_storage_info(halInfos[0]);
@@ -341,7 +341,7 @@
});
if (!ret.isOk()) {
- LOG_TO(SYSTEM, ERROR) << "getStorageInfo failed with " << ret.description();
+ LOG(ERROR) << "getStorageInfo failed with " << ret.description();
}
}
diff --git a/storaged/storaged_uid_monitor.cpp b/storaged/storaged_uid_monitor.cpp
index 55380ba..f47bf72 100644
--- a/storaged/storaged_uid_monitor.cpp
+++ b/storaged/storaged_uid_monitor.cpp
@@ -71,8 +71,7 @@
!ParseUint(fields[8], &io[BACKGROUND].write_bytes) ||
!ParseUint(fields[9], &io[FOREGROUND].fsync) ||
!ParseUint(fields[10], &io[BACKGROUND].fsync)) {
- LOG_TO(SYSTEM, WARNING) << "Invalid uid I/O stats: \""
- << s << "\"";
+ LOG(WARNING) << "Invalid uid I/O stats: \"" << s << "\"";
return false;
}
return true;
@@ -95,8 +94,7 @@
!ParseUint(fields[size - 3], &io[BACKGROUND].write_bytes) ||
!ParseUint(fields[size - 2], &io[FOREGROUND].fsync) ||
!ParseUint(fields[size - 1], &io[BACKGROUND].fsync)) {
- LOG_TO(SYSTEM, WARNING) << "Invalid task I/O stats: \""
- << s << "\"";
+ LOG(WARNING) << "Invalid task I/O stats: \"" << s << "\"";
return false;
}
comm = Join(std::vector<std::string>(
@@ -123,13 +121,13 @@
{
sp<IServiceManager> sm = defaultServiceManager();
if (sm == NULL) {
- LOG_TO(SYSTEM, ERROR) << "defaultServiceManager failed";
+ LOG(ERROR) << "defaultServiceManager failed";
return;
}
sp<IBinder> binder = sm->getService(String16("package_native"));
if (binder == NULL) {
- LOG_TO(SYSTEM, ERROR) << "getService package_native failed";
+ LOG(ERROR) << "getService package_native failed";
return;
}
@@ -137,8 +135,7 @@
std::vector<std::string> names;
binder::Status status = package_mgr->getNamesForUids(uids, &names);
if (!status.isOk()) {
- LOG_TO(SYSTEM, ERROR) << "package_native::getNamesForUids failed: "
- << status.exceptionMessage();
+ LOG(ERROR) << "package_native::getNamesForUids failed: " << status.exceptionMessage();
return;
}
@@ -158,7 +155,7 @@
std::unordered_map<uint32_t, uid_info> uid_io_stats;
std::string buffer;
if (!ReadFileToString(UID_IO_STATS_PATH, &buffer)) {
- PLOG_TO(SYSTEM, ERROR) << UID_IO_STATS_PATH << ": ReadFileToString failed";
+ PLOG(ERROR) << UID_IO_STATS_PATH << ": ReadFileToString failed";
return uid_io_stats;
}
diff --git a/trusty/Android.bp b/trusty/Android.bp
deleted file mode 100644
index 2fb2e19..0000000
--- a/trusty/Android.bp
+++ /dev/null
@@ -1,6 +0,0 @@
-subdirs = [
- "gatekeeper",
- "keymaster",
- "libtrusty",
- "storage/*",
-]
diff --git a/trusty/libtrusty/Android.bp b/trusty/libtrusty/Android.bp
index f6e9bee..8dba78d 100644
--- a/trusty/libtrusty/Android.bp
+++ b/trusty/libtrusty/Android.bp
@@ -12,10 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-subdirs = [
- "tipc-test",
-]
-
cc_library {
name: "libtrusty",
vendor: true,