Merge "snapshotctl: merge when boot"
diff --git a/adb/Android.bp b/adb/Android.bp
index 57872b0..9ef82bf 100644
--- a/adb/Android.bp
+++ b/adb/Android.bp
@@ -629,6 +629,7 @@
"libselinux",
],
test_suites: ["device-tests"],
+ require_root: true,
}
python_test_host {
diff --git a/debuggerd/debuggerd_test.cpp b/debuggerd/debuggerd_test.cpp
index c617c6c..c9a193c 100644
--- a/debuggerd/debuggerd_test.cpp
+++ b/debuggerd/debuggerd_test.cpp
@@ -195,9 +195,7 @@
void CrasherTest::FinishIntercept(int* result) {
InterceptResponse response;
- // Timeout for tombstoned intercept is 10 seconds.
- ssize_t rc =
- TIMEOUT(20, TEMP_FAILURE_RETRY(read(intercept_fd.get(), &response, sizeof(response))));
+ ssize_t rc = TIMEOUT(30, read(intercept_fd.get(), &response, sizeof(response)));
if (rc == -1) {
FAIL() << "failed to read response from tombstoned: " << strerror(errno);
} else if (rc == 0) {
@@ -244,7 +242,7 @@
void CrasherTest::AssertDeath(int signo) {
int status;
- pid_t pid = TIMEOUT(10, TEMP_FAILURE_RETRY(waitpid(crasher_pid, &status, 0)));
+ pid_t pid = TIMEOUT(30, waitpid(crasher_pid, &status, 0));
if (pid != crasher_pid) {
printf("failed to wait for crasher (expected pid %d, return value %d): %s\n", crasher_pid, pid,
strerror(errno));
diff --git a/fs_mgr/fs_mgr_fstab.cpp b/fs_mgr/fs_mgr_fstab.cpp
index 4dbacd7..e50f7c3 100644
--- a/fs_mgr/fs_mgr_fstab.cpp
+++ b/fs_mgr/fs_mgr_fstab.cpp
@@ -36,6 +36,7 @@
#include "fs_mgr_priv.h"
+using android::base::EndsWith;
using android::base::ParseByteCount;
using android::base::ParseInt;
using android::base::ReadFileToString;
@@ -598,7 +599,7 @@
return boot_devices;
}
-FstabEntry BuildGsiUserdataFstabEntry() {
+FstabEntry BuildDsuUserdataFstabEntry() {
constexpr uint32_t kFlags = MS_NOATIME | MS_NOSUID | MS_NODEV;
FstabEntry userdata = {
@@ -627,7 +628,12 @@
return false;
}
-void TransformFstabForGsi(Fstab* fstab) {
+} // namespace
+
+void TransformFstabForDsu(Fstab* fstab, const std::vector<std::string>& dsu_partitions) {
+ static constexpr char kGsiKeys[] =
+ "/avb/q-gsi.avbpubkey:/avb/r-gsi.avbpubkey:/avb/s-gsi.avbpubkey";
+ // Convert userdata
// Inherit fstab properties for userdata.
FstabEntry userdata;
if (FstabEntry* entry = GetEntryForMountPoint(fstab, "/data")) {
@@ -639,19 +645,75 @@
userdata.key_dir += "/gsi";
}
} else {
- userdata = BuildGsiUserdataFstabEntry();
- }
-
- if (EraseFstabEntry(fstab, "/system")) {
- fstab->emplace_back(BuildGsiSystemFstabEntry());
+ userdata = BuildDsuUserdataFstabEntry();
}
if (EraseFstabEntry(fstab, "/data")) {
fstab->emplace_back(userdata);
}
-}
-} // namespace
+ // Convert others
+ for (auto&& partition : dsu_partitions) {
+ if (!EndsWith(partition, gsi::kDsuPostfix)) {
+ continue;
+ }
+ // userdata has been handled
+ if (StartsWith(partition, "user")) {
+ continue;
+ }
+ // dsu_partition_name = corresponding_partition_name + kDsuPostfix
+ // e.g.
+ // system_gsi for system
+ // product_gsi for product
+ // vendor_gsi for vendor
+ std::string lp_name = partition.substr(0, partition.length() - strlen(gsi::kDsuPostfix));
+ std::string mount_point = "/" + lp_name;
+ std::vector<FstabEntry*> entries = GetEntriesForMountPoint(fstab, mount_point);
+ if (entries.empty()) {
+ FstabEntry entry = {
+ .blk_device = partition,
+ .mount_point = mount_point,
+ .fs_type = "ext4",
+ .flags = MS_RDONLY,
+ .fs_options = "barrier=1",
+ .avb_keys = kGsiKeys,
+ // .logical_partition_name is required to look up AVB Hashtree descriptors.
+ .logical_partition_name = "system"};
+ entry.fs_mgr_flags.wait = true;
+ entry.fs_mgr_flags.logical = true;
+ entry.fs_mgr_flags.first_stage_mount = true;
+ // Use the system key which may be in the vbmeta or vbmeta_system
+ // TODO: b/141284191
+ entry.vbmeta_partition = "vbmeta";
+ fstab->emplace_back(entry);
+ entry.vbmeta_partition = "vbmeta_system";
+ fstab->emplace_back(entry);
+ } else {
+ // If the corresponding partition exists, transform all its Fstab
+ // by pointing .blk_device to the DSU partition.
+ for (auto&& entry : entries) {
+ entry->blk_device = partition;
+ if (entry->avb_keys.size() > 0) {
+ entry->avb_keys += ":";
+ }
+ // If the DSU is signed by OEM, the original Fstab already has the information
+ // required by avb, otherwise the DSU is GSI and will need the avb_keys as listed
+ // below.
+ entry->avb_keys += kGsiKeys;
+ }
+ // Make sure the ext4 is included to support GSI.
+ auto partition_ext4 =
+ std::find_if(fstab->begin(), fstab->end(), [&](const auto& entry) {
+ return entry.mount_point == mount_point && entry.fs_type == "ext4";
+ });
+ if (partition_ext4 == fstab->end()) {
+ auto new_entry = *GetEntryForMountPoint(fstab, mount_point);
+ new_entry.fs_type = "ext4";
+ fstab->emplace_back(new_entry);
+ }
+ }
+ }
+}
bool ReadFstabFromFile(const std::string& path, Fstab* fstab) {
auto fstab_file = std::unique_ptr<FILE, decltype(&fclose)>{fopen(path.c_str(), "re"), fclose};
@@ -667,7 +729,9 @@
return false;
}
if (!is_proc_mounts && !access(android::gsi::kGsiBootedIndicatorFile, F_OK)) {
- TransformFstabForGsi(fstab);
+ std::string lp_names;
+ ReadFileToString(gsi::kGsiLpNamesFile, &lp_names);
+ TransformFstabForDsu(fstab, Split(lp_names, ","));
}
SkipMountingPartitions(fstab);
@@ -779,6 +843,21 @@
return nullptr;
}
+std::vector<FstabEntry*> GetEntriesForMountPoint(Fstab* fstab, const std::string& path) {
+ std::vector<FstabEntry*> entries;
+ if (fstab == nullptr) {
+ return entries;
+ }
+
+ for (auto& entry : *fstab) {
+ if (entry.mount_point == path) {
+ entries.emplace_back(&entry);
+ }
+ }
+
+ return entries;
+}
+
std::set<std::string> GetBootDevices() {
// First check the kernel commandline, then try the device tree otherwise
std::string dt_file_name = get_android_dt_dir() + "/boot_devices";
@@ -798,23 +877,6 @@
return ExtraBootDevices(fstab);
}
-FstabEntry BuildGsiSystemFstabEntry() {
- // .logical_partition_name is required to look up AVB Hashtree descriptors.
- FstabEntry system = {
- .blk_device = "system_gsi",
- .mount_point = "/system",
- .fs_type = "ext4",
- .flags = MS_RDONLY,
- .fs_options = "barrier=1",
- // could add more keys separated by ':'.
- .avb_keys = "/avb/q-gsi.avbpubkey:/avb/r-gsi.avbpubkey:/avb/s-gsi.avbpubkey",
- .logical_partition_name = "system"};
- system.fs_mgr_flags.wait = true;
- system.fs_mgr_flags.logical = true;
- system.fs_mgr_flags.first_stage_mount = true;
- return system;
-}
-
std::string GetVerityDeviceName(const FstabEntry& entry) {
std::string base_device;
if (entry.mount_point == "/") {
diff --git a/fs_mgr/include_fstab/fstab/fstab.h b/fs_mgr/include_fstab/fstab/fstab.h
index c7193ab..d999ae1 100644
--- a/fs_mgr/include_fstab/fstab/fstab.h
+++ b/fs_mgr/include_fstab/fstab/fstab.h
@@ -101,9 +101,18 @@
bool SkipMountingPartitions(Fstab* fstab);
FstabEntry* GetEntryForMountPoint(Fstab* fstab, const std::string& path);
+// The Fstab can contain multiple entries for the same mount point with different configurations.
+std::vector<FstabEntry*> GetEntriesForMountPoint(Fstab* fstab, const std::string& path);
-// Helper method to build a GSI fstab entry for mounting /system.
-FstabEntry BuildGsiSystemFstabEntry();
+// This method builds DSU fstab entries and transfer the fstab.
+//
+// fstab points to the unmodified fstab.
+//
+// dsu_partitions contains partition names, e.g.
+// dsu_partitions[0] = "system_gsi"
+// dsu_partitions[1] = "userdata_gsi"
+// dsu_partitions[2] = ...
+void TransformFstabForDsu(Fstab* fstab, const std::vector<std::string>& dsu_partitions);
std::set<std::string> GetBootDevices();
diff --git a/init/first_stage_mount.cpp b/init/first_stage_mount.cpp
index 4a1bc5a..9121bac 100644
--- a/init/first_stage_mount.cpp
+++ b/init/first_stage_mount.cpp
@@ -50,12 +50,13 @@
using android::fs_mgr::AvbHandleStatus;
using android::fs_mgr::AvbHashtreeResult;
using android::fs_mgr::AvbUniquePtr;
-using android::fs_mgr::BuildGsiSystemFstabEntry;
using android::fs_mgr::Fstab;
using android::fs_mgr::FstabEntry;
using android::fs_mgr::ReadDefaultFstab;
using android::fs_mgr::ReadFstabFromDt;
using android::fs_mgr::SkipMountingPartitions;
+using android::fs_mgr::TransformFstabForDsu;
+using android::init::WriteFile;
using android::snapshot::SnapshotManager;
using namespace std::literals;
@@ -596,14 +597,14 @@
}
void FirstStageMount::UseGsiIfPresent() {
- std::string metadata_file, error;
+ std::string error;
- if (!android::gsi::CanBootIntoGsi(&metadata_file, &error)) {
+ if (!android::gsi::CanBootIntoGsi(&error)) {
LOG(INFO) << "GSI " << error << ", proceeding with normal boot";
return;
}
- auto metadata = android::fs_mgr::ReadFromImageFile(metadata_file.c_str());
+ auto metadata = android::fs_mgr::ReadFromImageFile(gsi::kDsuLpMetadataFile);
if (!metadata) {
LOG(ERROR) << "GSI partition layout could not be read";
return;
@@ -627,14 +628,16 @@
return;
}
- // Replace the existing system fstab entry.
- auto system_partition = std::find_if(fstab_.begin(), fstab_.end(), [](const auto& entry) {
- return entry.mount_point == "/system";
- });
- if (system_partition != fstab_.end()) {
- fstab_.erase(system_partition);
+ std::string lp_names = "";
+ std::vector<std::string> dsu_partitions;
+ for (auto&& partition : metadata->partitions) {
+ auto name = fs_mgr::GetPartitionName(partition);
+ dsu_partitions.push_back(name);
+ lp_names += name + ",";
}
- fstab_.emplace_back(BuildGsiSystemFstabEntry());
+ // Publish the logical partition names for TransformFstabForDsu
+ WriteFile(gsi::kGsiLpNamesFile, lp_names);
+ TransformFstabForDsu(&fstab_, dsu_partitions);
gsi_not_on_userdata_ = (super_name != "userdata");
}
diff --git a/init/uevent_listener.cpp b/init/uevent_listener.cpp
index ac633776..416d942 100644
--- a/init/uevent_listener.cpp
+++ b/init/uevent_listener.cpp
@@ -171,7 +171,7 @@
return RegenerateUeventsForDir(d.get(), callback);
}
-static const char* kRegenerationPaths[] = {"/sys/class", "/sys/block", "/sys/devices"};
+static const char* kRegenerationPaths[] = {"/sys/devices"};
void UeventListener::RegenerateUevents(const ListenerCallback& callback) const {
for (const auto path : kRegenerationPaths) {
diff --git a/libpackagelistparser/Android.bp b/libpackagelistparser/Android.bp
index 0740e7d..b56dcdb 100644
--- a/libpackagelistparser/Android.bp
+++ b/libpackagelistparser/Android.bp
@@ -19,4 +19,5 @@
"libpackagelistparser",
],
test_suites: ["device-tests"],
+ require_root: true,
}
diff --git a/libutils/include/utils/Trace.h b/libutils/include/utils/Trace.h
index 4b9c91e..fec0ffa 100644
--- a/libutils/include/utils/Trace.h
+++ b/libutils/include/utils/Trace.h
@@ -17,7 +17,12 @@
#ifndef ANDROID_TRACE_H
#define ANDROID_TRACE_H
-#if defined(__ANDROID__)
+#if defined(_WIN32)
+
+#define ATRACE_NAME(...)
+#define ATRACE_CALL()
+
+#else // !_WIN32
#include <stdint.h>
@@ -51,11 +56,6 @@
} // namespace android
-#else // !__ANDROID__
-
-#define ATRACE_NAME(...)
-#define ATRACE_CALL()
-
-#endif // __ANDROID__
+#endif // _WIN32
#endif // ANDROID_TRACE_H
diff --git a/property_service/libpropertyinfoserializer/Android.bp b/property_service/libpropertyinfoserializer/Android.bp
index 51c1226..aa02a3a 100644
--- a/property_service/libpropertyinfoserializer/Android.bp
+++ b/property_service/libpropertyinfoserializer/Android.bp
@@ -1,7 +1,6 @@
cc_defaults {
name: "propertyinfoserializer_defaults",
host_supported: true,
- vendor_available: true,
cpp_std: "experimental",
cppflags: [
"-Wall",
@@ -9,8 +8,8 @@
"-Werror",
],
static_libs: [
- "libpropertyinfoparser",
"libbase",
+ "libpropertyinfoparser",
],
}
diff --git a/rootdir/etc/ld.config.legacy.txt b/rootdir/etc/ld.config.legacy.txt
index c47b7f6..bb8d4d0 100644
--- a/rootdir/etc/ld.config.legacy.txt
+++ b/rootdir/etc/ld.config.legacy.txt
@@ -179,6 +179,7 @@
namespace.neuralnetworks.link.default.shared_libs += liblog.so
namespace.neuralnetworks.link.default.shared_libs += libm.so
namespace.neuralnetworks.link.default.shared_libs += libnativewindow.so
+namespace.neuralnetworks.link.default.shared_libs += libneuralnetworks_packageinfo.so
namespace.neuralnetworks.link.default.shared_libs += libsync.so
namespace.neuralnetworks.link.default.shared_libs += libvndksupport.so
diff --git a/rootdir/etc/ld.config.txt b/rootdir/etc/ld.config.txt
index 5b92d48..60035aa 100644
--- a/rootdir/etc/ld.config.txt
+++ b/rootdir/etc/ld.config.txt
@@ -420,6 +420,7 @@
namespace.neuralnetworks.link.default.shared_libs += liblog.so
namespace.neuralnetworks.link.default.shared_libs += libm.so
namespace.neuralnetworks.link.default.shared_libs += libnativewindow.so
+namespace.neuralnetworks.link.default.shared_libs += libneuralnetworks_packageinfo.so
namespace.neuralnetworks.link.default.shared_libs += libsync.so
namespace.neuralnetworks.link.default.shared_libs += libvndksupport.so
@@ -641,6 +642,7 @@
namespace.neuralnetworks.link.system.shared_libs += liblog.so
namespace.neuralnetworks.link.system.shared_libs += libm.so
namespace.neuralnetworks.link.system.shared_libs += libnativewindow.so
+namespace.neuralnetworks.link.system.shared_libs += libneuralnetworks_packageinfo.so
namespace.neuralnetworks.link.system.shared_libs += libsync.so
namespace.neuralnetworks.link.system.shared_libs += libvndksupport.so
@@ -782,6 +784,7 @@
namespace.neuralnetworks.link.default.shared_libs += liblog.so
namespace.neuralnetworks.link.default.shared_libs += libm.so
namespace.neuralnetworks.link.default.shared_libs += libnativewindow.so
+namespace.neuralnetworks.link.default.shared_libs += libneuralnetworks_packageinfo.so
namespace.neuralnetworks.link.default.shared_libs += libsync.so
namespace.neuralnetworks.link.default.shared_libs += libvndksupport.so
diff --git a/rootdir/etc/ld.config.vndk_lite.txt b/rootdir/etc/ld.config.vndk_lite.txt
index 8a27c7b..b9b95a6 100644
--- a/rootdir/etc/ld.config.vndk_lite.txt
+++ b/rootdir/etc/ld.config.vndk_lite.txt
@@ -344,6 +344,7 @@
namespace.neuralnetworks.link.default.shared_libs += liblog.so
namespace.neuralnetworks.link.default.shared_libs += libm.so
namespace.neuralnetworks.link.default.shared_libs += libnativewindow.so
+namespace.neuralnetworks.link.default.shared_libs += libneuralnetworks_packageinfo.so
namespace.neuralnetworks.link.default.shared_libs += libsync.so
namespace.neuralnetworks.link.default.shared_libs += libvndksupport.so
@@ -445,6 +446,7 @@
namespace.neuralnetworks.link.default.shared_libs += liblog.so
namespace.neuralnetworks.link.default.shared_libs += libm.so
namespace.neuralnetworks.link.default.shared_libs += libnativewindow.so
+namespace.neuralnetworks.link.default.shared_libs += libneuralnetworks_packageinfo.so
namespace.neuralnetworks.link.default.shared_libs += libsync.so
namespace.neuralnetworks.link.default.shared_libs += libvndksupport.so
@@ -585,6 +587,7 @@
namespace.neuralnetworks.link.default.shared_libs += liblog.so
namespace.neuralnetworks.link.default.shared_libs += libm.so
namespace.neuralnetworks.link.default.shared_libs += libnativewindow.so
+namespace.neuralnetworks.link.default.shared_libs += libneuralnetworks_packageinfo.so
namespace.neuralnetworks.link.default.shared_libs += libsync.so
namespace.neuralnetworks.link.default.shared_libs += libvndksupport.so
diff --git a/rootdir/init.environ.rc.in b/rootdir/init.environ.rc.in
index 17f6596..50005d9 100644
--- a/rootdir/init.environ.rc.in
+++ b/rootdir/init.environ.rc.in
@@ -5,7 +5,7 @@
export ANDROID_ASSETS /system/app
export ANDROID_DATA /data
export ANDROID_STORAGE /storage
- export ANDROID_RUNTIME_ROOT /apex/com.android.art
+ export ANDROID_ART_ROOT /apex/com.android.art
export ANDROID_I18N_ROOT /apex/com.android.i18n
export ANDROID_TZDATA_ROOT /apex/com.android.tzdata
export EXTERNAL_STORAGE /sdcard
diff --git a/rootdir/init.rc b/rootdir/init.rc
index d5fed5a..0fa6efc 100644
--- a/rootdir/init.rc
+++ b/rootdir/init.rc
@@ -154,6 +154,14 @@
mkdir /mnt/user/0/self 0755 root root
mkdir /mnt/user/0/emulated 0755 root root
mkdir /mnt/user/0/emulated/0 0755 root root
+
+ # Prepare directories for pass through processes
+ mkdir /mnt/pass_through 0755 root root
+ mkdir /mnt/pass_through/0 0755 root root
+ mkdir /mnt/pass_through/0/self 0755 root root
+ mkdir /mnt/pass_through/0/emulated 0755 root root
+ mkdir /mnt/pass_through/0/emulated/0 0755 root root
+
mkdir /mnt/expand 0771 system system
mkdir /mnt/appfuse 0711 root root
@@ -678,6 +686,8 @@
# Mount default storage into root namespace
mount none /mnt/user/0 /storage bind rec
mount none none /storage slave rec
+ # Bootstrap the emulated volume for the pass_through directory for user 0
+ mount none /data/media /mnt/pass_through/0/emulated bind rec
on zygote-start && property:persist.sys.fuse=false
# Mount default storage into root namespace
mount none /mnt/runtime/default /storage bind rec