Merge "Remove unnecessary std::move" into main
diff --git a/fs_mgr/fs_mgr.cpp b/fs_mgr/fs_mgr.cpp
index 6052699..76578dd 100644
--- a/fs_mgr/fs_mgr.cpp
+++ b/fs_mgr/fs_mgr.cpp
@@ -38,8 +38,10 @@
#include <array>
#include <chrono>
+#include <functional>
#include <map>
#include <memory>
+#include <numeric>
#include <string>
#include <string_view>
#include <thread>
@@ -64,7 +66,6 @@
#include <fs_mgr/file_wait.h>
#include <fs_mgr_overlayfs.h>
#include <fscrypt/fscrypt.h>
-#include <fstab/fstab.h>
#include <libdm/dm.h>
#include <libdm/loop_control.h>
#include <liblp/metadata_format.h>
@@ -81,7 +82,7 @@
#define F2FS_FSCK_BIN "/system/bin/fsck.f2fs"
#define MKSWAP_BIN "/system/bin/mkswap"
#define TUNE2FS_BIN "/system/bin/tune2fs"
-#define RESIZE2FS_BIN "/system/bin/resize2fs"
+#define RESIZE2FS_BIN "/system/bin/resize2fs"
#define FSCK_LOG_FILE "/dev/fscklogs/log"
@@ -137,8 +138,8 @@
static void log_fs_stat(const std::string& blk_device, int fs_stat) {
std::string msg =
android::base::StringPrintf("\nfs_stat,%s,0x%x\n", blk_device.c_str(), fs_stat);
- android::base::unique_fd fd(TEMP_FAILURE_RETRY(
- open(FSCK_LOG_FILE, O_WRONLY | O_CLOEXEC | O_APPEND | O_CREAT, 0664)));
+ android::base::unique_fd fd(TEMP_FAILURE_RETRY(open(FSCK_LOG_FILE, O_WRONLY | O_CLOEXEC |
+ O_APPEND | O_CREAT, 0664)));
if (fd == -1 || !android::base::WriteStringToFd(msg, fd)) {
LWARNING << __FUNCTION__ << "() cannot log " << msg;
}
@@ -592,7 +593,7 @@
// Must give `-T now` to prevent last_fsck_time from growing too large,
// otherwise, tune2fs won't enable metadata_csum.
- const char* tune2fs_args[] = {TUNE2FS_BIN, "-O", "metadata_csum,64bit,extent",
+ const char* tune2fs_args[] = {TUNE2FS_BIN, "-O", "metadata_csum,64bit,extent",
"-T", "now", blk_device.c_str()};
const char* resize2fs_args[] = {RESIZE2FS_BIN, "-b", blk_device.c_str()};
@@ -1429,34 +1430,6 @@
return access(fs_mgr_metadata_encryption_in_progress_file_name(entry).c_str(), R_OK) == 0;
}
-FstabEntry* LocateFormattableEntry(FstabEntry* const begin, FstabEntry* const end) {
- const bool dev_option_enabled =
- android::base::GetBoolProperty("ro.product.build.16k_page.enabled", false);
- FstabEntry* f2fs_entry = nullptr;
- for (auto iter = begin; iter->blk_device == begin->blk_device && iter < end; iter++) {
- if (iter->fs_mgr_flags.formattable) {
- if (getpagesize() != 4096 && is_f2fs(iter->fs_type) && dev_option_enabled) {
- f2fs_entry = iter;
- continue;
- }
- if (f2fs_entry) {
- LOG(INFO) << "Skipping F2FS format for block device " << iter->blk_device << " @ "
- << iter->mount_point
- << " in non-4K mode for dev option enabled devices, "
- "as these devices need to toggle between 4K/16K mode, and F2FS does "
- "not support page_size != block_size configuration.";
- }
- return iter;
- }
- }
- if (f2fs_entry) {
- LOG(INFO) << "Using F2FS for " << f2fs_entry->blk_device << " @ " << f2fs_entry->mount_point
- << " even though we are in non-4K mode. Device might require a data wipe after "
- "going back to 4K mode, as F2FS does not support page_size != block_size";
- }
- return f2fs_entry;
-}
-
// When multiple fstab records share the same mount_point, it will try to mount each
// one in turn, and ignore any duplicates after a first successful mount.
// Returns -1 on error, and FS_MGR_MNTALL_* otherwise.
@@ -1567,8 +1540,8 @@
}
}
- int last_idx_inspected = -1;
- const int top_idx = i;
+ int last_idx_inspected;
+ int top_idx = i;
int attempted_idx = -1;
bool encryption_interrupted = WasMetadataEncryptionInterrupted(current_entry);
@@ -1618,8 +1591,7 @@
// Success! Go get the next one.
continue;
}
- auto formattable_entry =
- LocateFormattableEntry(fstab->data() + top_idx, fstab->data() + fstab->size());
+
// Mounting failed, understand why and retry.
wiped = partition_wiped(current_entry.blk_device.c_str());
if (mount_errno != EBUSY && mount_errno != EACCES &&
@@ -1647,12 +1619,12 @@
encryptable = FS_MGR_MNTALL_DEV_IS_METADATA_ENCRYPTED;
set_type_property(encryptable);
- if (!call_vdc({"cryptfs", "encryptFstab", formattable_entry->blk_device,
- formattable_entry->mount_point, "true" /* shouldFormat */,
- formattable_entry->fs_type,
- formattable_entry->fs_mgr_flags.is_zoned ? "true" : "false",
- std::to_string(formattable_entry->length),
- android::base::Join(formattable_entry->user_devices, ' ')},
+ if (!call_vdc({"cryptfs", "encryptFstab", current_entry.blk_device,
+ current_entry.mount_point, "true" /* shouldFormat */,
+ current_entry.fs_type,
+ current_entry.fs_mgr_flags.is_zoned ? "true" : "false",
+ std::to_string(current_entry.length),
+ android::base::Join(current_entry.user_devices, ' ')},
nullptr)) {
LERROR << "Encryption failed";
} else {
@@ -1661,7 +1633,7 @@
}
}
- if (fs_mgr_do_format(*formattable_entry) == 0) {
+ if (fs_mgr_do_format(current_entry) == 0) {
// Let's replay the mount actions.
i = top_idx - 1;
continue;
@@ -1777,12 +1749,12 @@
int ret = prepare_fs_for_mount(entry.blk_device, entry, mount_point);
// Wiped case doesn't require to try __mount below.
if (ret & FS_STAT_INVALID_MAGIC) {
- return FS_MGR_DOMNT_FAILED;
+ return FS_MGR_DOMNT_FAILED;
}
ret = __mount(entry.blk_device, mount_point, entry);
if (ret) {
- ret = (errno == EBUSY) ? FS_MGR_DOMNT_BUSY : FS_MGR_DOMNT_FAILED;
+ ret = (errno == EBUSY) ? FS_MGR_DOMNT_BUSY : FS_MGR_DOMNT_FAILED;
}
return ret;
diff --git a/fs_mgr/include/fs_mgr/roots.h b/fs_mgr/include/fs_mgr/roots.h
index 65c59cf..e19f9ad 100644
--- a/fs_mgr/include/fs_mgr/roots.h
+++ b/fs_mgr/include/fs_mgr/roots.h
@@ -29,6 +29,8 @@
// first match or nullptr.
FstabEntry* GetEntryForPath(Fstab* fstab, const std::string& path);
+std::vector<FstabEntry*> GetEntriesForPath(Fstab* fstab, const std::string& path);
+
// Make sure that the volume 'path' is on is mounted.
// * If 'mount_point' is nullptr, use mount point in fstab. Caller can call
// fs_mgr_ensure_path_unmounted() with the same 'path' argument to unmount.
diff --git a/fs_mgr/libsnapshot/Android.bp b/fs_mgr/libsnapshot/Android.bp
index 4828c4c..50efb03 100644
--- a/fs_mgr/libsnapshot/Android.bp
+++ b/fs_mgr/libsnapshot/Android.bp
@@ -46,7 +46,6 @@
"libfstab",
"libsnapuserd_client",
"libz",
- "libselinux",
],
header_libs: [
"libfiemap_headers",
@@ -112,6 +111,9 @@
static_libs: [
"libfs_mgr_binder",
],
+ whole_static_libs: [
+ "libselinux",
+ ],
}
cc_library {
@@ -130,6 +132,9 @@
static_libs: [
"libsnapshot_cow",
],
+ whole_static_libs: [
+ "libselinux",
+ ],
}
cc_library_static {
@@ -144,6 +149,7 @@
],
static_libs: [
"libfs_mgr",
+ "libselinux",
],
}
@@ -161,6 +167,9 @@
static_libs: [
"libfs_mgr",
],
+ whole_static_libs: [
+ "libselinux",
+ ],
}
cc_defaults {
@@ -243,6 +252,7 @@
"libfs_mgr",
"libgmock",
"libgtest",
+ "libselinux",
],
}
@@ -285,7 +295,6 @@
],
auto_gen_config: true,
require_root: true,
- compile_multilib: "first",
}
cc_test {
@@ -298,6 +307,15 @@
"vts",
"general-tests",
],
+ compile_multilib: "both",
+ multilib: {
+ lib32: {
+ suffix: "32",
+ },
+ lib64: {
+ suffix: "64",
+ },
+ },
test_options: {
min_shipping_api_level: 30,
},
@@ -315,6 +333,7 @@
test_suites: [
"general-tests",
],
+ compile_multilib: "64",
test_options: {
// Legacy VAB launched in Android R.
min_shipping_api_level: 30,
diff --git a/fs_mgr/libsnapshot/snapuserd/Android.bp b/fs_mgr/libsnapshot/snapuserd/Android.bp
index 734066b..8d0bf7d 100644
--- a/fs_mgr/libsnapshot/snapuserd/Android.bp
+++ b/fs_mgr/libsnapshot/snapuserd/Android.bp
@@ -239,9 +239,19 @@
test_options: {
min_shipping_api_level: 30,
},
+
+ compile_multilib: "both",
+ multilib: {
+ lib32: {
+ suffix: "32",
+ },
+ lib64: {
+ suffix: "64",
+ },
+ },
+
auto_gen_config: true,
require_root: true,
- compile_multilib: "first",
}
cc_test {
diff --git a/init/devices.cpp b/init/devices.cpp
index 5560c20..f2bb9d2 100644
--- a/init/devices.cpp
+++ b/init/devices.cpp
@@ -283,7 +283,7 @@
void DeviceHandler::MakeDevice(const std::string& path, bool block, int major, int minor,
const std::vector<std::string>& links) const {
- auto[mode, uid, gid] = GetDevicePermissions(path, links);
+ auto [mode, uid, gid] = GetDevicePermissions(path, links);
mode |= (block ? S_IFBLK : S_IFCHR);
std::string secontext;
@@ -330,11 +330,11 @@
if (gid != s.st_gid) {
new_group = gid;
}
- if (mode != s.st_mode) {
- if (chmod(path.c_str(), mode) != 0) {
- PLOG(ERROR) << "Cannot chmod " << path << " to " << mode;
+ if (mode != s.st_mode) {
+ if (chmod(path.c_str(), mode) != 0) {
+ PLOG(ERROR) << "Cannot chmod " << path << " to " << mode;
+ }
}
- }
} else {
PLOG(ERROR) << "Cannot stat " << path;
}
@@ -531,7 +531,7 @@
if (!ReadFileToString(boot_id_path, &boot_id)) {
PLOG(ERROR) << "Cannot duplicate ashmem device node. Failed to read " << boot_id_path;
return;
- };
+ }
boot_id = Trim(boot_id);
Uevent dup_ashmem_uevent = uevent;
@@ -542,10 +542,10 @@
}
void DeviceHandler::HandleUevent(const Uevent& uevent) {
- if (uevent.action == "add" || uevent.action == "change" ||
- uevent.action == "bind" || uevent.action == "online") {
- FixupSysPermissions(uevent.path, uevent.subsystem);
- }
+ if (uevent.action == "add" || uevent.action == "change" || uevent.action == "bind" ||
+ uevent.action == "online") {
+ FixupSysPermissions(uevent.path, uevent.subsystem);
+ }
// if it's not a /dev device, nothing to do
if (uevent.major < 0 || uevent.minor < 0) return;
diff --git a/rootdir/Android.mk b/rootdir/Android.mk
index f866e9b..ac9ca85 100644
--- a/rootdir/Android.mk
+++ b/rootdir/Android.mk
@@ -35,7 +35,8 @@
ln -sf /system/etc $(TARGET_ROOT_OUT)/etc; \
ln -sf /data/user_de/0/com.android.shell/files/bugreports $(TARGET_ROOT_OUT)/bugreports; \
ln -sfn /sys/kernel/debug $(TARGET_ROOT_OUT)/d; \
- ln -sf /storage/self/primary $(TARGET_ROOT_OUT)/sdcard
+ ln -sf /storage/self/primary $(TARGET_ROOT_OUT)/sdcard; \
+ ln -sf /product/etc/security/adb_keys $(TARGET_ROOT_OUT)/adb_keys
ALL_ROOTDIR_SYMLINKS := \
$(TARGET_ROOT_OUT)/bin \
@@ -150,4 +151,3 @@
init.environ.rc-soong := $(call intermediates-dir-for,ETC,init.environ.rc-soong)/init.environ.rc-soong
$(eval $(call copy-one-file,$(init.environ.rc-soong),$(LOCAL_BUILT_MODULE)))
init.environ.rc-soong :=
-
diff --git a/shell_and_utilities/Android.bp b/shell_and_utilities/Android.bp
index d85f6ed..d5893de 100644
--- a/shell_and_utilities/Android.bp
+++ b/shell_and_utilities/Android.bp
@@ -18,6 +18,7 @@
"awk",
"bc",
"bzip2",
+ "cpu-target-features",
"fsck.exfat",
"ldd",
"logwrapper",