Workaround for Global ThinLTO
Global string literals are not initialized correctly with the new
config.
This change is a workaround by changing them into plain C literals until
we have a better solution.
Bug: 291033685
Test: adb-remount-test.sh
Change-Id: I178286133f55ff5dc11030fa132a9e6db0747ae7
diff --git a/fs_mgr/fs_mgr_overlayfs.cpp b/fs_mgr/fs_mgr_overlayfs.cpp
index 01827d6..82a8b8b 100644
--- a/fs_mgr/fs_mgr_overlayfs.cpp
+++ b/fs_mgr/fs_mgr_overlayfs.cpp
@@ -75,8 +75,8 @@
return access(path.c_str(), F_OK) == 0;
}
-const auto kLowerdirOption = "lowerdir="s;
-const auto kUpperdirOption = "upperdir="s;
+const auto kLowerdirOption = "lowerdir=";
+const auto kUpperdirOption = "upperdir=";
bool fs_mgr_in_recovery() {
// Check the existence of recovery binary instead of using the compile time
@@ -99,8 +99,8 @@
}
// list of acceptable overlayfs backing storage
-const auto kScratchMountPoint = "/mnt/scratch"s;
-const auto kCacheMountPoint = "/cache"s;
+const auto kScratchMountPoint = "/mnt/scratch";
+const auto kCacheMountPoint = "/cache";
bool IsABDevice() {
return !android::base::GetProperty("ro.boot.slot_suffix", "").empty();
@@ -158,7 +158,7 @@
(static_cast<uint64_t>(vst.f_bfree) * vst.f_frsize) >= kSizeThreshold;
}
-const auto kPhysicalDevice = "/dev/block/by-name/"s;
+const auto kPhysicalDevice = "/dev/block/by-name/";
constexpr char kScratchImageMetadata[] = "/metadata/gsi/remount/lp_metadata";
// Note: this is meant only for recovery/first-stage init.
@@ -182,7 +182,7 @@
}
// special case for system-as-root (taimen and others)
- auto blk_device = kPhysicalDevice + "system";
+ auto blk_device = std::string(kPhysicalDevice) + "system";
if (!fs_mgr_access(blk_device)) {
blk_device += fs_mgr_get_slot_suffix();
if (!fs_mgr_access(blk_device)) {
@@ -301,9 +301,9 @@
return ret;
}
-const auto kUpperName = "upper"s;
-const auto kWorkName = "work"s;
-const auto kOverlayTopDir = "/overlay"s;
+const auto kUpperName = "upper";
+const auto kWorkName = "work";
+const auto kOverlayTopDir = "/overlay";
std::string fs_mgr_get_overlayfs_candidate(const std::string& mount_point) {
if (!fs_mgr_is_dir(mount_point)) return "";
@@ -472,10 +472,10 @@
// Returns true if immediate unmount succeeded and the scratch mount point was
// removed.
bool fs_mgr_overlayfs_umount_scratch() {
- if (umount(kScratchMountPoint.c_str()) != 0) {
+ if (umount(kScratchMountPoint) != 0) {
return false;
}
- if (rmdir(kScratchMountPoint.c_str()) != 0 && errno != ENOENT) {
+ if (rmdir(kScratchMountPoint) != 0 && errno != ENOENT) {
PLOG(ERROR) << "rmdir " << kScratchMountPoint;
}
return true;
@@ -573,7 +573,7 @@
auto cleanup_all = mount_point.empty();
const auto partition_name = android::base::Basename(mount_point);
const auto oldpath = top + (cleanup_all ? "" : ("/" + partition_name));
- const auto newpath = cleanup_all ? overlay + "/." + kOverlayTopDir.substr(1) + ".teardown"
+ const auto newpath = cleanup_all ? overlay + "/." + (kOverlayTopDir + 1) + ".teardown"
: top + "/." + partition_name + ".teardown";
auto ret = fs_mgr_rm_all(newpath);
if (!rename(oldpath.c_str(), newpath.c_str())) {
@@ -853,7 +853,7 @@
if (!createcon.Ok()) {
return false;
}
- if (mkdir(kScratchMountPoint.c_str(), 0755) && (errno != EEXIST)) {
+ if (mkdir(kScratchMountPoint, 0755) && (errno != EEXIST)) {
PERROR << "create " << kScratchMountPoint;
return false;
}
@@ -884,7 +884,7 @@
return false;
}
if (!mounted) {
- rmdir(kScratchMountPoint.c_str());
+ rmdir(kScratchMountPoint);
return false;
}
return true;
@@ -1192,7 +1192,7 @@
// If the partition exists, assume first that it can be mounted.
if (partition_exists) {
if (MountScratch(scratch_device)) {
- if (fs_mgr_access(kScratchMountPoint + kOverlayTopDir) ||
+ if (fs_mgr_access(std::string(kScratchMountPoint) + kOverlayTopDir) ||
fs_mgr_filesystem_has_space(kScratchMountPoint)) {
return true;
}
@@ -1331,7 +1331,7 @@
if (!MountScratch(scratch_device, true /* readonly */)) {
return;
}
- auto has_overlayfs_dir = fs_mgr_access(kScratchMountPoint + kOverlayTopDir);
+ auto has_overlayfs_dir = fs_mgr_access(std::string(kScratchMountPoint) + kOverlayTopDir);
fs_mgr_overlayfs_umount_scratch();
if (has_overlayfs_dir) {
MountScratch(scratch_device);