Merge "Remove system/core/mkbootimg"
diff --git a/adb/daemon/usb.cpp b/adb/daemon/usb.cpp
index ac739c4..1abae87 100644
--- a/adb/daemon/usb.cpp
+++ b/adb/daemon/usb.cpp
@@ -169,12 +169,12 @@
};
struct UsbFfsConnection : public Connection {
- UsbFfsConnection(unique_fd* control, unique_fd read, unique_fd write,
+ UsbFfsConnection(unique_fd control, unique_fd read, unique_fd write,
std::promise<void> destruction_notifier)
: worker_started_(false),
stopped_(false),
destruction_notifier_(std::move(destruction_notifier)),
- control_fd_(control),
+ control_fd_(std::move(control)),
read_fd_(std::move(read)),
write_fd_(std::move(write)) {
LOG(INFO) << "UsbFfsConnection constructed";
@@ -183,6 +183,11 @@
PLOG(FATAL) << "failed to create eventfd";
}
+ monitor_event_fd_.reset(eventfd(0, EFD_CLOEXEC));
+ if (monitor_event_fd_ == -1) {
+ PLOG(FATAL) << "failed to create eventfd";
+ }
+
aio_context_ = ScopedAioContext::Create(kUsbReadQueueDepth + kUsbWriteQueueDepth);
}
@@ -194,6 +199,7 @@
// We need to explicitly close our file descriptors before we notify our destruction,
// because the thread listening on the future will immediately try to reopen the endpoint.
aio_context_.reset();
+ control_fd_.reset();
read_fd_.reset();
write_fd_.reset();
@@ -240,6 +246,13 @@
PLOG(FATAL) << "failed to notify worker eventfd to stop UsbFfsConnection";
}
CHECK_EQ(static_cast<size_t>(rc), sizeof(notify));
+
+ rc = adb_write(monitor_event_fd_.get(), ¬ify, sizeof(notify));
+ if (rc < 0) {
+ PLOG(FATAL) << "failed to notify monitor eventfd to stop UsbFfsConnection";
+ }
+
+ CHECK_EQ(static_cast<size_t>(rc), sizeof(notify));
}
private:
@@ -258,24 +271,33 @@
monitor_thread_ = std::thread([this]() {
adb_thread_setname("UsbFfs-monitor");
+ bool bound = false;
bool enabled = false;
bool running = true;
while (running) {
adb_pollfd pfd[2] = {
- {.fd = control_fd_->get(), .events = POLLIN, .revents = 0},
+ { .fd = control_fd_.get(), .events = POLLIN, .revents = 0 },
+ { .fd = monitor_event_fd_.get(), .events = POLLIN, .revents = 0 },
};
- int rc = TEMP_FAILURE_RETRY(adb_poll(pfd, 2, -1));
+ // If we don't see our first bind within a second, try again.
+ int timeout_ms = bound ? -1 : 1000;
+
+ int rc = TEMP_FAILURE_RETRY(adb_poll(pfd, 2, timeout_ms));
if (rc == -1) {
PLOG(FATAL) << "poll on USB control fd failed";
+ } else if (rc == 0) {
+ LOG(WARNING) << "timed out while waiting for FUNCTIONFS_BIND, trying again";
+ break;
}
if (pfd[1].revents) {
- // We were told to die, continue reading until FUNCTIONFS_UNBIND.
+ // We were told to die.
+ break;
}
struct usb_functionfs_event event;
- rc = TEMP_FAILURE_RETRY(adb_read(control_fd_->get(), &event, sizeof(event)));
+ rc = TEMP_FAILURE_RETRY(adb_read(control_fd_.get(), &event, sizeof(event)));
if (rc == -1) {
PLOG(FATAL) << "failed to read functionfs event";
} else if (rc == 0) {
@@ -291,10 +313,28 @@
switch (event.type) {
case FUNCTIONFS_BIND:
- LOG(FATAL) << "received FUNCTIONFS_BIND after already opened?";
+ if (bound) {
+ LOG(WARNING) << "received FUNCTIONFS_BIND while already bound?";
+ running = false;
+ break;
+ }
+
+ if (enabled) {
+ LOG(WARNING) << "received FUNCTIONFS_BIND while already enabled?";
+ running = false;
+ break;
+ }
+
+ bound = true;
break;
case FUNCTIONFS_ENABLE:
+ if (!bound) {
+ LOG(WARNING) << "received FUNCTIONFS_ENABLE while not bound?";
+ running = false;
+ break;
+ }
+
if (enabled) {
LOG(WARNING) << "received FUNCTIONFS_ENABLE while already enabled?";
running = false;
@@ -306,6 +346,10 @@
break;
case FUNCTIONFS_DISABLE:
+ if (!bound) {
+ LOG(WARNING) << "received FUNCTIONFS_DISABLE while not bound?";
+ }
+
if (!enabled) {
LOG(WARNING) << "received FUNCTIONFS_DISABLE while not enabled?";
}
@@ -319,6 +363,11 @@
LOG(WARNING) << "received FUNCTIONFS_UNBIND while still enabled?";
}
+ if (!bound) {
+ LOG(WARNING) << "received FUNCTIONFS_UNBIND when not bound?";
+ }
+
+ bound = false;
running = false;
break;
@@ -332,7 +381,7 @@
if ((event.u.setup.bRequestType & USB_DIR_IN)) {
LOG(INFO) << "acking device-to-host control transfer";
- ssize_t rc = adb_write(control_fd_->get(), "", 0);
+ ssize_t rc = adb_write(control_fd_.get(), "", 0);
if (rc != 0) {
PLOG(ERROR) << "failed to write empty packet to host";
break;
@@ -341,7 +390,7 @@
std::string buf;
buf.resize(event.u.setup.wLength + 1);
- ssize_t rc = adb_read(control_fd_->get(), buf.data(), buf.size());
+ ssize_t rc = adb_read(control_fd_.get(), buf.data(), buf.size());
if (rc != event.u.setup.wLength) {
LOG(ERROR)
<< "read " << rc
@@ -377,12 +426,6 @@
uint64_t dummy;
ssize_t rc = adb_read(worker_event_fd_.get(), &dummy, sizeof(dummy));
if (rc == -1) {
- if (errno == EINTR) {
- // We were interrupted either to stop, or because of a backtrace.
- // Check stopped_ again to see if we need to exit.
- continue;
- }
-
PLOG(FATAL) << "failed to read from eventfd";
} else if (rc == 0) {
LOG(FATAL) << "hit EOF on eventfd";
@@ -419,7 +462,6 @@
}
worker_thread_.join();
- worker_started_ = false;
}
void PrepareReadBlock(IoBlock* block, uint64_t id) {
@@ -637,13 +679,10 @@
std::once_flag error_flag_;
unique_fd worker_event_fd_;
+ unique_fd monitor_event_fd_;
ScopedAioContext aio_context_;
-
- // We keep a pointer to the control fd, so that we can reuse it to avoid USB reconfiguration,
- // and still be able to reset it to force a reopen after FUNCTIONFS_UNBIND or running into an
- // unexpected situation.
- unique_fd* control_fd_;
+ unique_fd control_fd_;
unique_fd read_fd_;
unique_fd write_fd_;
@@ -672,16 +711,15 @@
static void usb_ffs_open_thread() {
adb_thread_setname("usb ffs open");
- unique_fd control;
- unique_fd bulk_out;
- unique_fd bulk_in;
-
while (true) {
if (gFfsAioSupported.has_value() && !gFfsAioSupported.value()) {
LOG(INFO) << "failed to use nonblocking ffs, falling back to legacy";
return usb_init_legacy();
}
+ unique_fd control;
+ unique_fd bulk_out;
+ unique_fd bulk_in;
if (!open_functionfs(&control, &bulk_out, &bulk_in)) {
std::this_thread::sleep_for(1s);
continue;
@@ -692,7 +730,7 @@
std::promise<void> destruction_notifier;
std::future<void> future = destruction_notifier.get_future();
transport->SetConnection(std::make_unique<UsbFfsConnection>(
- &control, std::move(bulk_out), std::move(bulk_in),
+ std::move(control), std::move(bulk_out), std::move(bulk_in),
std::move(destruction_notifier)));
register_transport(transport);
future.wait();
diff --git a/adb/daemon/usb_ffs.cpp b/adb/daemon/usb_ffs.cpp
index 1b54022..a64ce40 100644
--- a/adb/daemon/usb_ffs.cpp
+++ b/adb/daemon/usb_ffs.cpp
@@ -297,32 +297,8 @@
PLOG(ERROR) << "failed to write USB strings";
return false;
}
-
- // Signal init after we've wwritten our descriptors.
+ // Signal only when writing the descriptors to ffs
android::base::SetProperty("sys.usb.ffs.ready", "1");
-
- // Read until we get FUNCTIONFS_BIND from the control endpoint.
- while (true) {
- struct usb_functionfs_event event;
- ssize_t rc = TEMP_FAILURE_RETRY(adb_read(control.get(), &event, sizeof(event)));
-
- if (rc == -1) {
- PLOG(FATAL) << "failed to read from FFS control fd";
- } else if (rc == 0) {
- LOG(WARNING) << "hit EOF on functionfs control fd during initialization";
- } else if (rc != sizeof(event)) {
- LOG(FATAL) << "read functionfs event of unexpected size, expected " << sizeof(event)
- << ", got " << rc;
- }
-
- if (event.type != FUNCTIONFS_BIND) {
- LOG(FATAL) << "first read on functionfs control fd returned non-bind: "
- << event.type;
- } else {
- break;
- }
- }
-
*out_control = std::move(control);
}
diff --git a/base/Android.bp b/base/Android.bp
index 25a9f68..58b6fb5 100644
--- a/base/Android.bp
+++ b/base/Android.bp
@@ -111,6 +111,9 @@
"libbase_headers",
],
export_header_lib_headers: ["libbase_headers"],
+ static_libs: ["fmtlib"],
+ whole_static_libs: ["fmtlib"],
+ export_static_lib_headers: ["fmtlib"],
}
cc_library_static {
@@ -119,6 +122,9 @@
sdk_version: "current",
stl: "c++_static",
export_include_dirs: ["include"],
+ static_libs: ["fmtlib_ndk"],
+ whole_static_libs: ["fmtlib_ndk"],
+ export_static_lib_headers: ["fmtlib_ndk"],
}
// Tests
@@ -176,3 +182,21 @@
},
test_suites: ["device-tests"],
}
+
+cc_benchmark {
+ name: "libbase_benchmark",
+ defaults: ["libbase_cflags_defaults"],
+
+ srcs: ["format_benchmark.cpp"],
+ shared_libs: ["libbase"],
+
+ compile_multilib: "both",
+ multilib: {
+ lib32: {
+ suffix: "32",
+ },
+ lib64: {
+ suffix: "64",
+ },
+ },
+}
diff --git a/base/format_benchmark.cpp b/base/format_benchmark.cpp
new file mode 100644
index 0000000..9590b23
--- /dev/null
+++ b/base/format_benchmark.cpp
@@ -0,0 +1,80 @@
+/*
+ * 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.
+ */
+
+#include "android-base/format.h"
+
+#include <limits>
+
+#include <benchmark/benchmark.h>
+
+#include "android-base/stringprintf.h"
+
+using android::base::StringPrintf;
+
+static void BenchmarkFormatInt(benchmark::State& state) {
+ for (auto _ : state) {
+ benchmark::DoNotOptimize(fmt::format("{} {} {}", 42, std::numeric_limits<int>::min(),
+ std::numeric_limits<int>::max()));
+ }
+}
+
+BENCHMARK(BenchmarkFormatInt);
+
+static void BenchmarkStringPrintfInt(benchmark::State& state) {
+ for (auto _ : state) {
+ benchmark::DoNotOptimize(StringPrintf("%d %d %d", 42, std::numeric_limits<int>::min(),
+ std::numeric_limits<int>::max()));
+ }
+}
+
+BENCHMARK(BenchmarkStringPrintfInt);
+
+static void BenchmarkFormatFloat(benchmark::State& state) {
+ for (auto _ : state) {
+ benchmark::DoNotOptimize(fmt::format("{} {} {}", 42.42, std::numeric_limits<float>::min(),
+ std::numeric_limits<float>::max()));
+ }
+}
+
+BENCHMARK(BenchmarkFormatFloat);
+
+static void BenchmarkStringPrintfFloat(benchmark::State& state) {
+ for (auto _ : state) {
+ benchmark::DoNotOptimize(StringPrintf("%f %f %f", 42.42, std::numeric_limits<float>::min(),
+ std::numeric_limits<float>::max()));
+ }
+}
+
+BENCHMARK(BenchmarkStringPrintfFloat);
+
+static void BenchmarkFormatStrings(benchmark::State& state) {
+ for (auto _ : state) {
+ benchmark::DoNotOptimize(fmt::format("{} hello there {}", "hi,", "!!"));
+ }
+}
+
+BENCHMARK(BenchmarkFormatStrings);
+
+static void BenchmarkStringPrintfStrings(benchmark::State& state) {
+ for (auto _ : state) {
+ benchmark::DoNotOptimize(StringPrintf("%s hello there %s", "hi,", "!!"));
+ }
+}
+
+BENCHMARK(BenchmarkStringPrintfStrings);
+
+// Run the benchmark
+BENCHMARK_MAIN();
diff --git a/base/include/android-base/format.h b/base/include/android-base/format.h
new file mode 100644
index 0000000..6799c1f
--- /dev/null
+++ b/base/include/android-base/format.h
@@ -0,0 +1,25 @@
+/*
+ * 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.
+ */
+
+#pragma once
+
+// We include fmtlib here as an alias, since libbase will have fmtlib statically linked already.
+// It is accessed through its normal fmt:: namespace.
+#include <fmt/core.h>
+#include <fmt/format.h>
+#include <fmt/ostream.h>
+#include <fmt/printf.h>
+#include <fmt/time.h>
diff --git a/base/include/android-base/result.h b/base/include/android-base/result.h
index 4a8e1ef..1b763af 100644
--- a/base/include/android-base/result.h
+++ b/base/include/android-base/result.h
@@ -42,10 +42,15 @@
// to the end of the failure string to aid in interacting with C APIs. Alternatively, an errno
// value can be directly specified via the Error() constructor.
//
-// ResultError can be used in the ostream when using Error to construct a Result<T>. In this case,
-// the string that the ResultError takes is passed through the stream normally, but the errno is
-// passed to the Result<T>. This can be used to pass errno from a failing C function up multiple
-// callers.
+// Errorf and ErrnoErrorf accept the format string syntax of the fmblib (https://fmt.dev).
+// Errorf("{} errors", num) is equivalent to Error() << num << " errors".
+//
+// ResultError can be used in the ostream and when using Error/Errorf to construct a Result<T>.
+// In this case, the string that the ResultError takes is passed through the stream normally, but
+// the errno is passed to the Result<T>. This can be used to pass errno from a failing C function up
+// multiple callers. Note that when the outer Result<T> is created with ErrnoError/ErrnoErrorf then
+// the errno from the inner ResultError is not passed. Also when multiple ResultError objects are
+// used, the errno of the last one is respected.
//
// ResultError can also directly construct a Result<T>. This is particularly useful if you have a
// function that return Result<T> but you have a Result<U> and want to return its error. In this
@@ -55,10 +60,10 @@
// Result<U> CalculateResult(const T& input) {
// U output;
// if (!SomeOtherCppFunction(input, &output)) {
-// return Error() << "SomeOtherCppFunction(" << input << ") failed";
+// return Errorf("SomeOtherCppFunction {} failed", input);
// }
// if (!c_api_function(output)) {
-// return ErrnoError() << "c_api_function(" << output << ") failed";
+// return ErrnoErrorf("c_api_function {} failed", output);
// }
// return output;
// }
@@ -75,6 +80,7 @@
#include <string>
#include "android-base/expected.h"
+#include "android-base/format.h"
namespace android {
namespace base {
@@ -147,16 +153,51 @@
Error& operator=(const Error&) = delete;
Error& operator=(Error&&) = delete;
+ template <typename... Args>
+ friend Error Errorf(const char* fmt, const Args&... args);
+
+ template <typename... Args>
+ friend Error ErrnoErrorf(const char* fmt, const Args&... args);
+
private:
+ Error(bool append_errno, int errno_to_append, const std::string& message)
+ : errno_(errno_to_append), append_errno_(append_errno) {
+ (*this) << message;
+ }
+
std::stringstream ss_;
int errno_;
- bool append_errno_;
+ const bool append_errno_;
};
inline Error ErrnoError() {
return Error(errno);
}
+inline int ErrorCode(int code) {
+ return code;
+}
+
+// Return the error code of the last ResultError object, if any.
+// Otherwise, return `code` as it is.
+template <typename T, typename... Args>
+inline int ErrorCode(int code, T&& t, const Args&... args) {
+ if constexpr (std::is_same_v<std::remove_cv_t<std::remove_reference_t<T>>, ResultError>) {
+ return ErrorCode(t.code(), args...);
+ }
+ return ErrorCode(code, args...);
+}
+
+template <typename... Args>
+inline Error Errorf(const char* fmt, const Args&... args) {
+ return Error(false, ErrorCode(0, args...), fmt::format(fmt, args...));
+}
+
+template <typename... Args>
+inline Error ErrnoErrorf(const char* fmt, const Args&... args) {
+ return Error(true, errno, fmt::format(fmt, args...));
+}
+
template <typename T>
using Result = android::base::expected<T, ResultError>;
diff --git a/base/result_test.cpp b/base/result_test.cpp
index e864b97..2ee4057 100644
--- a/base/result_test.cpp
+++ b/base/result_test.cpp
@@ -355,5 +355,68 @@
EXPECT_EQ(old_errno, result2.error().code());
}
+TEST(result, error_with_fmt) {
+ Result<int> result = Errorf("{} {}!", "hello", "world");
+ EXPECT_EQ("hello world!", result.error().message());
+
+ result = Errorf("{} {}!", std::string("hello"), std::string("world"));
+ EXPECT_EQ("hello world!", result.error().message());
+
+ result = Errorf("{h} {w}!", fmt::arg("w", "world"), fmt::arg("h", "hello"));
+ EXPECT_EQ("hello world!", result.error().message());
+
+ result = Errorf("hello world!");
+ EXPECT_EQ("hello world!", result.error().message());
+
+ Result<int> result2 = Errorf("error occurred with {}", result.error());
+ EXPECT_EQ("error occurred with hello world!", result2.error().message());
+
+ constexpr int test_errno = 6;
+ errno = test_errno;
+ result = ErrnoErrorf("{} {}!", "hello", "world");
+ EXPECT_EQ(test_errno, result.error().code());
+ EXPECT_EQ("hello world!: "s + strerror(test_errno), result.error().message());
+}
+
+TEST(result, error_with_fmt_carries_errno) {
+ constexpr int inner_errno = 6;
+ errno = inner_errno;
+ Result<int> inner_result = ErrnoErrorf("inner failure");
+ errno = 0;
+ EXPECT_EQ(inner_errno, inner_result.error().code());
+
+ // outer_result is created with Errorf, but its error code is got from inner_result.
+ Result<int> outer_result = Errorf("outer failure caused by {}", inner_result.error());
+ EXPECT_EQ(inner_errno, outer_result.error().code());
+ EXPECT_EQ("outer failure caused by inner failure: "s + strerror(inner_errno),
+ outer_result.error().message());
+
+ // now both result objects are created with ErrnoErrorf. errno from the inner_result
+ // is not passed to outer_result.
+ constexpr int outer_errno = 10;
+ errno = outer_errno;
+ outer_result = ErrnoErrorf("outer failure caused by {}", inner_result.error());
+ EXPECT_EQ(outer_errno, outer_result.error().code());
+ EXPECT_EQ("outer failure caused by inner failure: "s + strerror(inner_errno) + ": "s +
+ strerror(outer_errno),
+ outer_result.error().message());
+}
+
+TEST(result, errno_chaining_multiple) {
+ constexpr int errno1 = 6;
+ errno = errno1;
+ Result<int> inner1 = ErrnoErrorf("error1");
+
+ constexpr int errno2 = 10;
+ errno = errno2;
+ Result<int> inner2 = ErrnoErrorf("error2");
+
+ // takes the error code of inner2 since its the last one.
+ Result<int> outer = Errorf("two errors: {}, {}", inner1.error(), inner2.error());
+ EXPECT_EQ(errno2, outer.error().code());
+ EXPECT_EQ("two errors: error1: "s + strerror(errno1) + ", error2: "s + strerror(errno2),
+ outer.error().message());
+}
+
} // namespace base
} // namespace android
diff --git a/fastboot/device/commands.cpp b/fastboot/device/commands.cpp
index 2e9c2d6..409ef70 100644
--- a/fastboot/device/commands.cpp
+++ b/fastboot/device/commands.cpp
@@ -39,6 +39,7 @@
#include "flashing.h"
#include "utility.h"
+using android::fs_mgr::MetadataBuilder;
using ::android::hardware::hidl_string;
using ::android::hardware::boot::V1_0::BoolResult;
using ::android::hardware::boot::V1_0::CommandResult;
@@ -46,8 +47,6 @@
using ::android::hardware::fastboot::V1_0::Result;
using ::android::hardware::fastboot::V1_0::Status;
-using namespace android::fs_mgr;
-
struct VariableHandlers {
// Callback to retrieve the value of a single variable.
std::function<bool(FastbootDevice*, const std::vector<std::string>&, std::string*)> get;
@@ -94,7 +93,7 @@
{FB_VAR_HAS_SLOT, {GetHasSlot, GetAllPartitionArgsNoSlot}},
{FB_VAR_SLOT_SUCCESSFUL, {GetSlotSuccessful, nullptr}},
{FB_VAR_SLOT_UNBOOTABLE, {GetSlotUnbootable, nullptr}},
- {FB_VAR_PARTITION_SIZE, {::GetPartitionSize, GetAllPartitionArgsWithSlot}},
+ {FB_VAR_PARTITION_SIZE, {GetPartitionSize, GetAllPartitionArgsWithSlot}},
{FB_VAR_PARTITION_TYPE, {GetPartitionType, GetAllPartitionArgsWithSlot}},
{FB_VAR_IS_LOGICAL, {GetPartitionIsLogical, GetAllPartitionArgsWithSlot}},
{FB_VAR_IS_USERSPACE, {GetIsUserspace, nullptr}},
@@ -340,7 +339,7 @@
PartitionBuilder::PartitionBuilder(FastbootDevice* device, const std::string& partition_name)
: device_(device) {
std::string slot_suffix = GetSuperSlotSuffix(device, partition_name);
- slot_number_ = SlotNumberForSlotSuffix(slot_suffix);
+ slot_number_ = android::fs_mgr::SlotNumberForSlotSuffix(slot_suffix);
auto super_device = FindPhysicalPartition(fs_mgr_get_super_partition_name(slot_number_));
if (!super_device) {
return;
@@ -350,7 +349,7 @@
}
bool PartitionBuilder::Write() {
- std::unique_ptr<LpMetadata> metadata = builder_->Export();
+ auto metadata = builder_->Export();
if (!metadata) {
return false;
}
@@ -381,7 +380,7 @@
return device->WriteFail("Partition already exists");
}
- Partition* partition = builder->AddPartition(partition_name, 0);
+ auto partition = builder->AddPartition(partition_name, 0);
if (!partition) {
return device->WriteFail("Failed to add partition");
}
@@ -437,7 +436,7 @@
return device->WriteFail("Could not open super partition");
}
- Partition* partition = builder->FindPartition(partition_name);
+ auto partition = builder->FindPartition(partition_name);
if (!partition) {
return device->WriteFail("Partition does not exist");
}
@@ -466,7 +465,7 @@
class AutoMountMetadata {
public:
AutoMountMetadata() {
- Fstab proc_mounts;
+ android::fs_mgr::Fstab proc_mounts;
if (!ReadFstabFromFile("/proc/mounts", &proc_mounts)) {
LOG(ERROR) << "Could not read /proc/mounts";
return;
@@ -494,7 +493,7 @@
explicit operator bool() const { return mounted_; }
private:
- Fstab fstab_;
+ android::fs_mgr::Fstab fstab_;
bool mounted_ = false;
bool should_unmount_ = false;
};
diff --git a/fs_mgr/fs_mgr_fstab.cpp b/fs_mgr/fs_mgr_fstab.cpp
index 403f9be..31790b1 100644
--- a/fs_mgr/fs_mgr_fstab.cpp
+++ b/fs_mgr/fs_mgr_fstab.cpp
@@ -171,6 +171,18 @@
fs_options.append(","); // appends a comma if not the first
}
fs_options.append(flag);
+
+ if (entry->fs_type == "f2fs" && StartsWith(flag, "reserve_root=")) {
+ std::string arg;
+ if (auto equal_sign = flag.find('='); equal_sign != std::string::npos) {
+ arg = flag.substr(equal_sign + 1);
+ }
+ if (!ParseInt(arg, &entry->reserved_size)) {
+ LWARNING << "Warning: reserve_root= flag malformed: " << arg;
+ } else {
+ entry->reserved_size <<= 12;
+ }
+ }
}
}
entry->fs_options = std::move(fs_options);
diff --git a/fs_mgr/libfiemap_writer/Android.bp b/fs_mgr/libfiemap_writer/Android.bp
index 32fc3d2..ed209aa 100644
--- a/fs_mgr/libfiemap_writer/Android.bp
+++ b/fs_mgr/libfiemap_writer/Android.bp
@@ -30,6 +30,7 @@
],
static_libs: [
+ "libdm",
"libext4_utils",
],
diff --git a/fs_mgr/libfiemap_writer/fiemap_writer.cpp b/fs_mgr/libfiemap_writer/fiemap_writer.cpp
index e3803d5..f064436 100644
--- a/fs_mgr/libfiemap_writer/fiemap_writer.cpp
+++ b/fs_mgr/libfiemap_writer/fiemap_writer.cpp
@@ -37,10 +37,13 @@
#include <android-base/stringprintf.h>
#include <android-base/strings.h>
#include <android-base/unique_fd.h>
+#include <libdm/dm.h>
namespace android {
namespace fiemap_writer {
+using namespace android::dm;
+
// We are expecting no more than 512 extents in a fiemap of the file we create.
// If we find more, then it is treated as error for now.
static constexpr const uint32_t kMaxExtents = 512;
@@ -87,14 +90,57 @@
}
static bool DeviceMapperStackPop(const std::string& bdev, std::string* bdev_raw) {
- // TODO: Stop popping the device mapper stack if dm-linear target is found
+ *bdev_raw = bdev;
+
if (!::android::base::StartsWith(bdev, "dm-")) {
// We are at the bottom of the device mapper stack.
- *bdev_raw = bdev;
return true;
}
- std::string dm_leaf_dir = ::android::base::StringPrintf("/sys/block/%s/slaves", bdev.c_str());
+ // Get the device name.
+ auto dm_name_file = "/sys/block/" + bdev + "/dm/name";
+ std::string dm_name;
+ if (!android::base::ReadFileToString(dm_name_file, &dm_name)) {
+ PLOG(ERROR) << "Could not read file: " << dm_name_file;
+ return false;
+ }
+ dm_name = android::base::Trim(dm_name);
+
+ auto& dm = DeviceMapper::Instance();
+ std::vector<DeviceMapper::TargetInfo> table;
+ if (!dm.GetTableInfo(dm_name, &table)) {
+ LOG(ERROR) << "Could not read device-mapper table for " << dm_name << " at " << bdev;
+ return false;
+ }
+
+ // The purpose of libfiemap_writer is to provide an extent-based view into
+ // a file. This is difficult if devices are not layered in a 1:1 manner;
+ // we would have to translate and break up extents based on the actual
+ // block mapping. Since this is too complex, we simply stop processing
+ // the device-mapper stack if we encounter a complex case.
+ //
+ // It is up to the caller to decide whether stopping at a virtual block
+ // device is allowable. In most cases it is not, because we want either
+ // "userdata" or an external volume. It is useful for tests however.
+ // Callers can check by comparing the device number to that of userdata,
+ // or by checking whether is a device-mapper node.
+ if (table.size() > 1) {
+ LOG(INFO) << "Stopping at complex table for " << dm_name << " at " << bdev;
+ return true;
+ }
+ const auto& entry = table[0].spec;
+ std::string target_type(std::string(entry.target_type, sizeof(entry.target_type)).c_str());
+ if (target_type != "bow" && target_type != "default-key" && target_type != "crypt") {
+ LOG(INFO) << "Stopping at complex target-type " << target_type << " for " << dm_name
+ << " at " << bdev;
+ return true;
+ }
+ if (entry.sector_start != 0) {
+ LOG(INFO) << "Stopping at target-type with non-zero starting sector";
+ return true;
+ }
+
+ auto dm_leaf_dir = "/sys/block/" + bdev + "/slaves";
auto d = std::unique_ptr<DIR, decltype(&closedir)>(opendir(dm_leaf_dir.c_str()), closedir);
if (d == nullptr) {
PLOG(ERROR) << "Failed to open: " << dm_leaf_dir;
diff --git a/fs_mgr/libfiemap_writer/include/libfiemap_writer/fiemap_writer.h b/fs_mgr/libfiemap_writer/include/libfiemap_writer/fiemap_writer.h
index 9486122..ee79262 100644
--- a/fs_mgr/libfiemap_writer/include/libfiemap_writer/fiemap_writer.h
+++ b/fs_mgr/libfiemap_writer/include/libfiemap_writer/fiemap_writer.h
@@ -60,10 +60,17 @@
// FiemapWriter::Open).
static bool HasPinnedExtents(const std::string& file_path);
- // Returns the underlying block device of a file. This will look past device-mapper layers.
- // If an intermediate device-mapper layer would not maintain a 1:1 mapping (i.e. is a non-
- // trivial dm-linear), then this will fail. If device-mapper nodes are encountered, then
- // |uses_dm| will be set to true.
+ // Returns the underlying block device of a file. This will look past device-mapper layers
+ // as long as each layer would not change block mappings (i.e., dm-crypt, dm-bow, and dm-
+ // default-key tables are okay; dm-linear is not). If a mapping such as dm-linear is found,
+ // it will be returned in place of any physical block device.
+ //
+ // It is the caller's responsibility to check whether the returned block device is acceptable.
+ // Gsid, for example, will only accept /dev/block/by-name/userdata as the bottom device.
+ // Callers can check the device name (dm- or loop prefix), inspect sysfs, or compare the major
+ // number against a boot device.
+ //
+ // If device-mapper nodes were encountered, then |uses_dm| will be set to true.
static bool GetBlockDeviceForFile(const std::string& file_path, std::string* bdev_path,
bool* uses_dm = nullptr);
diff --git a/fs_mgr/liblp/Android.bp b/fs_mgr/liblp/Android.bp
index 7039994..b504161 100644
--- a/fs_mgr/liblp/Android.bp
+++ b/fs_mgr/liblp/Android.bp
@@ -14,6 +14,16 @@
// limitations under the License.
//
+liblp_lib_deps = [
+ "libbase",
+ "liblog",
+ "libcrypto",
+ "libcrypto_utils",
+ "libsparse",
+ "libext4_utils",
+ "libz",
+]
+
cc_library {
name: "liblp",
host_supported: true,
@@ -30,15 +40,7 @@
"utility.cpp",
"writer.cpp",
],
- shared_libs: [
- "libbase",
- "liblog",
- "libcrypto",
- "libcrypto_utils",
- "libsparse",
- "libext4_utils",
- "libz",
- ],
+ shared_libs: liblp_lib_deps,
target: {
windows: {
enabled: true,
@@ -53,24 +55,28 @@
}
cc_test {
- name: "liblp_test",
+ name: "liblp_test_static",
defaults: ["fs_mgr_defaults"],
cppflags: [
"-Wno-unused-parameter",
],
static_libs: [
"libgmock",
- ],
- shared_libs: [
- "liblp",
- "libbase",
"libfs_mgr",
- "libsparse",
- ],
+ "liblp",
+ ] + liblp_lib_deps,
+ stl: "libc++_static",
srcs: [
"builder_test.cpp",
"io_test.cpp",
"test_partition_opener.cpp",
"utility_test.cpp",
],
+ target: {
+ android: {
+ static_libs: [
+ "libcutils",
+ ],
+ },
+ },
}
diff --git a/fs_mgr/liblp/AndroidTest.xml b/fs_mgr/liblp/AndroidTest.xml
index 007a302..fe1002c 100644
--- a/fs_mgr/liblp/AndroidTest.xml
+++ b/fs_mgr/liblp/AndroidTest.xml
@@ -21,8 +21,8 @@
</target_preparer>
<test class="com.android.tradefed.testtype.VtsMultiDeviceTest">
<option name="test-module-name" value="VtsKernelLiblpTest"/>
- <option name="binary-test-source" value="_32bit::DATA/nativetest/liblp_test/liblp_test" />
- <option name="binary-test-source" value="_64bit::DATA/nativetest64/liblp_test/liblp_test" />
+ <option name="binary-test-source" value="_32bit::DATA/nativetest/liblp_test_static/liblp_test_static" />
+ <option name="binary-test-source" value="_64bit::DATA/nativetest64/liblp_test_static/liblp_test_static" />
<option name="binary-test-type" value="gtest"/>
<option name="test-timeout" value="1m"/>
<option name="precondition-first-api-level" value="29" />
diff --git a/fs_mgr/liblp/builder.cpp b/fs_mgr/liblp/builder.cpp
index 41c01da..25a042f 100644
--- a/fs_mgr/liblp/builder.cpp
+++ b/fs_mgr/liblp/builder.cpp
@@ -214,7 +214,7 @@
sABOverrideValue = ab_device;
}
-MetadataBuilder::MetadataBuilder() : auto_slot_suffixing_(false), ignore_slot_suffixing_(false) {
+MetadataBuilder::MetadataBuilder() : auto_slot_suffixing_(false) {
memset(&geometry_, 0, sizeof(geometry_));
geometry_.magic = LP_METADATA_GEOMETRY_MAGIC;
geometry_.struct_size = sizeof(geometry_);
@@ -443,11 +443,6 @@
LERROR << "Could not find partition group: " << group_name;
return nullptr;
}
- if (IsABDevice() && !auto_slot_suffixing_ && name != "scratch" && !ignore_slot_suffixing_ &&
- GetPartitionSlotSuffix(name).empty()) {
- LERROR << "Unsuffixed partition not allowed on A/B device: " << name;
- return nullptr;
- }
partitions_.push_back(std::make_unique<Partition>(name, group_name, attributes));
return partitions_.back().get();
}
@@ -1049,10 +1044,6 @@
auto_slot_suffixing_ = true;
}
-void MetadataBuilder::IgnoreSlotSuffixing() {
- ignore_slot_suffixing_ = true;
-}
-
bool MetadataBuilder::IsABDevice() const {
if (sABOverrideSet) {
return sABOverrideValue;
diff --git a/fs_mgr/liblp/builder_test.cpp b/fs_mgr/liblp/builder_test.cpp
index 45c3ede..34c68d4 100644
--- a/fs_mgr/liblp/builder_test.cpp
+++ b/fs_mgr/liblp/builder_test.cpp
@@ -772,15 +772,6 @@
EXPECT_FALSE(builder->ImportPartitions(*exported.get(), {"system"}));
}
-TEST_F(BuilderTest, UnsuffixedPartitions) {
- MetadataBuilder::OverrideABForTesting(true);
- unique_ptr<MetadataBuilder> builder = MetadataBuilder::New(1024 * 1024, 1024, 2);
- ASSERT_NE(builder, nullptr);
-
- ASSERT_EQ(builder->AddPartition("system", 0), nullptr);
- ASSERT_NE(builder->AddPartition("system_a", 0), nullptr);
-}
-
TEST_F(BuilderTest, ABExtents) {
BlockDeviceInfo device_info("super", 10_GiB, 768 * 1024, 0, 4096);
diff --git a/fs_mgr/liblp/include/liblp/builder.h b/fs_mgr/liblp/include/liblp/builder.h
index c706f2a..e70c552 100644
--- a/fs_mgr/liblp/include/liblp/builder.h
+++ b/fs_mgr/liblp/include/liblp/builder.h
@@ -345,7 +345,6 @@
std::vector<std::unique_ptr<PartitionGroup>> groups_;
std::vector<LpMetadataBlockDevice> block_devices_;
bool auto_slot_suffixing_;
- bool ignore_slot_suffixing_;
};
// Read BlockDeviceInfo for a given block device. This always returns false
diff --git a/init/keychords_test.cpp b/init/keychords_test.cpp
index a3baeb1..33373d4 100644
--- a/init/keychords_test.cpp
+++ b/init/keychords_test.cpp
@@ -29,7 +29,6 @@
#include <vector>
#include <android-base/properties.h>
-#include <android-base/stringprintf.h>
#include <android-base/strings.h>
#include <gtest/gtest.h>
diff --git a/init/keyword_map.h b/init/keyword_map.h
index c95fc73..7837bb3 100644
--- a/init/keyword_map.h
+++ b/init/keyword_map.h
@@ -14,14 +14,11 @@
* limitations under the License.
*/
-#ifndef _INIT_KEYWORD_MAP_H_
-#define _INIT_KEYWORD_MAP_H_
+#pragma once
#include <map>
#include <string>
-#include <android-base/stringprintf.h>
-
#include "result.h"
namespace android {
@@ -37,8 +34,6 @@
}
const Result<Function> FindFunction(const std::vector<std::string>& args) const {
- using android::base::StringPrintf;
-
if (args.empty()) return Error() << "Keyword needed, but not provided";
auto& keyword = args[0];
@@ -46,7 +41,7 @@
auto function_info_it = map().find(keyword);
if (function_info_it == map().end()) {
- return Error() << StringPrintf("Invalid keyword '%s'", keyword.c_str());
+ return Errorf("Invalid keyword '{}'", keyword);
}
auto function_info = function_info_it->second;
@@ -54,17 +49,17 @@
auto min_args = std::get<0>(function_info);
auto max_args = std::get<1>(function_info);
if (min_args == max_args && num_args != min_args) {
- return Error() << StringPrintf("%s requires %zu argument%s", keyword.c_str(), min_args,
- (min_args > 1 || min_args == 0) ? "s" : "");
+ return Errorf("{} requires {} argument{}", keyword, min_args,
+ (min_args > 1 || min_args == 0) ? "s" : "");
}
if (num_args < min_args || num_args > max_args) {
if (max_args == std::numeric_limits<decltype(max_args)>::max()) {
- return Error() << StringPrintf("%s requires at least %zu argument%s",
- keyword.c_str(), min_args, min_args > 1 ? "s" : "");
+ return Errorf("{} requires at least {} argument{}", keyword, min_args,
+ min_args > 1 ? "s" : "");
} else {
- return Error() << StringPrintf("%s requires between %zu and %zu arguments",
- keyword.c_str(), min_args, max_args);
+ return Errorf("{} requires between {} and {} arguments", keyword, min_args,
+ max_args);
}
}
@@ -79,5 +74,3 @@
} // namespace init
} // namespace android
-
-#endif
diff --git a/init/property_service.cpp b/init/property_service.cpp
index ab5dd61..14bb819 100644
--- a/init/property_service.cpp
+++ b/init/property_service.cpp
@@ -645,8 +645,14 @@
while (isspace(*key)) key++;
}
- load_properties_from_file(fn, key, properties);
+ std::string raw_filename(fn);
+ std::string expanded_filename;
+ if (!expand_props(raw_filename, &expanded_filename)) {
+ LOG(ERROR) << "Could not expand filename '" << raw_filename << "'";
+ continue;
+ }
+ load_properties_from_file(expanded_filename.c_str(), key, properties);
} else {
value = strchr(key, '=');
if (!value) continue;
diff --git a/init/reboot.cpp b/init/reboot.cpp
index fbc03c2..eaba3cc 100644
--- a/init/reboot.cpp
+++ b/init/reboot.cpp
@@ -41,7 +41,6 @@
#include <android-base/logging.h>
#include <android-base/macros.h>
#include <android-base/properties.h>
-#include <android-base/stringprintf.h>
#include <android-base/strings.h>
#include <android-base/unique_fd.h>
#include <bootloader_message/bootloader_message.h>
@@ -62,7 +61,6 @@
using android::base::GetBoolProperty;
using android::base::Split;
-using android::base::StringPrintf;
using android::base::Timer;
using android::base::unique_fd;
using android::base::WriteStringToFile;
diff --git a/init/result.h b/init/result.h
index 8c1f91e..b70dd1b 100644
--- a/init/result.h
+++ b/init/result.h
@@ -22,6 +22,8 @@
#include <android-base/result.h>
using android::base::ErrnoError;
+using android::base::ErrnoErrorf;
using android::base::Error;
+using android::base::Errorf;
using android::base::Result;
using android::base::ResultError;
diff --git a/init/service.cpp b/init/service.cpp
index b6a7c33..4fe374c 100644
--- a/init/service.cpp
+++ b/init/service.cpp
@@ -332,12 +332,11 @@
const std::string& arg = args[i];
int res = LookupCap(arg);
if (res < 0) {
- return Error() << StringPrintf("invalid capability '%s'", arg.c_str());
+ return Errorf("invalid capability '{}'", arg);
}
unsigned int cap = static_cast<unsigned int>(res); // |res| is >= 0.
if (cap > last_valid_cap) {
- return Error() << StringPrintf("capability '%s' not supported by the kernel",
- arg.c_str());
+ return Errorf("capability '{}' not supported by the kernel", arg);
}
(*capabilities_)[cap] = true;
}
@@ -402,8 +401,8 @@
if (!ParseInt(args[1], &proc_attr_.priority,
static_cast<int>(ANDROID_PRIORITY_HIGHEST), // highest is negative
static_cast<int>(ANDROID_PRIORITY_LOWEST))) {
- return Error() << StringPrintf("process priority value must be range %d - %d",
- ANDROID_PRIORITY_HIGHEST, ANDROID_PRIORITY_LOWEST);
+ return Errorf("process priority value must be range {} - {}", ANDROID_PRIORITY_HIGHEST,
+ ANDROID_PRIORITY_LOWEST);
}
return {};
}
diff --git a/libprocessgroup/Android.bp b/libprocessgroup/Android.bp
index 52a297c..618a5c5 100644
--- a/libprocessgroup/Android.bp
+++ b/libprocessgroup/Android.bp
@@ -24,9 +24,9 @@
],
name: "libprocessgroup",
host_supported: true,
+ native_bridge_supported: true,
recovery_available: true,
vendor_available: true,
- native_bridge_supported: true,
vndk: {
enabled: true,
support_system_process: true,
diff --git a/libprocessgroup/cgroup_map.cpp b/libprocessgroup/cgroup_map.cpp
index 92fcd1e..9797d76 100644
--- a/libprocessgroup/cgroup_map.cpp
+++ b/libprocessgroup/cgroup_map.cpp
@@ -70,8 +70,8 @@
bool CgroupController::IsUsable() const {
if (!HasValue()) return false;
- uint32_t flags = ACgroupController_getFlags(controller_);
- return (flags & CGROUPRC_CONTROLLER_FLAG_MOUNTED) != 0;
+ static bool enabled = (access(GetProcsFilePath("", 0, 0).c_str(), F_OK) == 0);
+ return enabled;
}
std::string CgroupController::GetTasksFilePath(const std::string& rel_path) const {
@@ -160,7 +160,6 @@
const ACgroupController* controller = ACgroupFile_getController(i);
LOG(INFO) << "\t" << ACgroupController_getName(controller) << " ver "
<< ACgroupController_getVersion(controller) << " path "
- << ACgroupController_getFlags(controller) << " flags "
<< ACgroupController_getPath(controller);
}
}
diff --git a/libprocessgroup/cgrouprc/cgroup_controller.cpp b/libprocessgroup/cgrouprc/cgroup_controller.cpp
index 5a326e5..d064d31 100644
--- a/libprocessgroup/cgrouprc/cgroup_controller.cpp
+++ b/libprocessgroup/cgrouprc/cgroup_controller.cpp
@@ -27,11 +27,6 @@
return controller->version();
}
-uint32_t ACgroupController_getFlags(const ACgroupController* controller) {
- CHECK(controller != nullptr);
- return controller->flags();
-}
-
const char* ACgroupController_getName(const ACgroupController* controller) {
CHECK(controller != nullptr);
return controller->name();
diff --git a/libprocessgroup/cgrouprc/include/android/cgrouprc.h b/libprocessgroup/cgrouprc/include/android/cgrouprc.h
index ffc9f0b..0f6a9cd 100644
--- a/libprocessgroup/cgrouprc/include/android/cgrouprc.h
+++ b/libprocessgroup/cgrouprc/include/android/cgrouprc.h
@@ -66,18 +66,11 @@
__INTRODUCED_IN(29);
/**
- * Flag bitmask used in ACgroupController_getFlags
+ * Flag bitmask to be used when ACgroupController_getFlags can be exported
*/
#define CGROUPRC_CONTROLLER_FLAG_MOUNTED 0x1
/**
- * Returns the flags bitmask of the given controller.
- * If the given controller is null, return 0.
- */
-__attribute__((warn_unused_result)) uint32_t ACgroupController_getFlags(const ACgroupController*)
- __INTRODUCED_IN(29);
-
-/**
* Returns the name of the given controller.
* If the given controller is null, return nullptr.
*/
diff --git a/libprocessgroup/cgrouprc/libcgrouprc.llndk.txt b/libprocessgroup/cgrouprc/libcgrouprc.llndk.txt
index ea3df33..91df392 100644
--- a/libprocessgroup/cgrouprc/libcgrouprc.llndk.txt
+++ b/libprocessgroup/cgrouprc/libcgrouprc.llndk.txt
@@ -4,7 +4,6 @@
ACgroupFile_getControllerCount;
ACgroupFile_getController;
ACgroupController_getVersion;
- ACgroupController_getFlags;
ACgroupController_getName;
ACgroupController_getPath;
local:
diff --git a/libziparchive/include/ziparchive/zip_archive.h b/libziparchive/include/ziparchive/zip_archive.h
index a56a4a2..463851c 100644
--- a/libziparchive/include/ziparchive/zip_archive.h
+++ b/libziparchive/include/ziparchive/zip_archive.h
@@ -190,7 +190,8 @@
* archive and lower negative values on failure.
*/
int32_t Next(void* cookie, ZipEntry* data, std::string* name);
-// TODO: remove this when everyone's moved over to std::string.
+int32_t Next(void* cookie, ZipEntry* data, std::string_view* name);
+// TODO: remove this when everyone's moved over to std::string/std::string_view.
int32_t Next(void* cookie, ZipEntry* data, ZipString* name);
/*
diff --git a/libziparchive/zip_archive.cc b/libziparchive/zip_archive.cc
index f4b6c74..e966295 100644
--- a/libziparchive/zip_archive.cc
+++ b/libziparchive/zip_archive.cc
@@ -748,10 +748,19 @@
}
int32_t Next(void* cookie, ZipEntry* data, std::string* name) {
+ std::string_view sv;
+ int32_t result = Next(cookie, data, &sv);
+ if (result == 0 && name) {
+ *name = std::string(sv);
+ }
+ return result;
+}
+
+int32_t Next(void* cookie, ZipEntry* data, std::string_view* name) {
ZipString zs;
int32_t result = Next(cookie, data, &zs);
- if (result == 0) {
- *name = std::string(reinterpret_cast<const char*>(zs.name), zs.name_length);
+ if (result == 0 && name) {
+ *name = std::string_view(reinterpret_cast<const char*>(zs.name), zs.name_length);
}
return result;
}
diff --git a/libziparchive/zip_archive_test.cc b/libziparchive/zip_archive_test.cc
index b6ca9ec..8781ab7 100644
--- a/libziparchive/zip_archive_test.cc
+++ b/libziparchive/zip_archive_test.cc
@@ -107,6 +107,26 @@
close(fd);
}
+TEST(ziparchive, Iteration_std_string_view) {
+ ZipArchiveHandle handle;
+ ASSERT_EQ(0, OpenArchiveWrapper(kValidZip, &handle));
+
+ void* iteration_cookie;
+ ASSERT_EQ(0, StartIteration(handle, &iteration_cookie));
+
+ ZipEntry data;
+ std::vector<std::string_view> names;
+ std::string_view name;
+ while (Next(iteration_cookie, &data, &name) == 0) names.push_back(name);
+
+ // Assert that the names are as expected.
+ std::vector<std::string_view> expected_names{"a.txt", "b.txt", "b/", "b/c.txt", "b/d.txt"};
+ std::sort(names.begin(), names.end());
+ ASSERT_EQ(expected_names, names);
+
+ CloseArchive(handle);
+}
+
static void AssertIterationOrder(const std::string_view prefix, const std::string_view suffix,
const std::vector<std::string>& expected_names_sorted) {
ZipArchiveHandle handle;
diff --git a/rootdir/etc/ld.config.txt b/rootdir/etc/ld.config.txt
index 7f129f8..b1616d3 100644
--- a/rootdir/etc/ld.config.txt
+++ b/rootdir/etc/ld.config.txt
@@ -617,6 +617,7 @@
# TODO(b/122876336): Remove libpac.so once it's migrated to Webview
namespace.default.link.runtime.shared_libs += libpac.so
+namespace.default.link.runtime.shared_libs += %SANITIZER_RUNTIME_LIBRARIES%
namespace.default.link.resolv.shared_libs = libnetd_resolv.so
diff --git a/rootdir/etc/ld.config.vndk_lite.txt b/rootdir/etc/ld.config.vndk_lite.txt
index 0880be0..9212408 100644
--- a/rootdir/etc/ld.config.vndk_lite.txt
+++ b/rootdir/etc/ld.config.vndk_lite.txt
@@ -428,6 +428,7 @@
# TODO(b/122876336): Remove libpac.so once it's migrated to Webview
namespace.default.link.runtime.shared_libs += libpac.so
+namespace.default.link.runtime.shared_libs += %SANITIZER_RUNTIME_LIBRARIES%
namespace.default.link.resolv.shared_libs = libnetd_resolv.so