summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTreehugger Robot <android-test-infra-autosubmit@system.gserviceaccount.com>2024-05-02 20:11:52 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2024-05-02 20:11:52 +0000
commit4dced90fdccc4c1cab1e92517b05f8558ee3282c (patch)
tree8a88b6d70665c8ec6fb1c7c9e35c54273a77fbd6
parent31b1582797b93504431439d1e80c37b4c3bd2cc7 (diff)
parentd18649eab31dc8d2ffb6e6935c118319f90dc9f7 (diff)
downloadcore-4dced90fdccc4c1cab1e92517b05f8558ee3282c.tar.gz
Merge "Add device= in Fstab" into main
-rw-r--r--fs_mgr/fs_mgr.cpp13
-rw-r--r--fs_mgr/fs_mgr_format.cpp21
-rw-r--r--fs_mgr/libfstab/fstab.cpp36
-rw-r--r--fs_mgr/libfstab/include/fstab/fstab.h3
4 files changed, 51 insertions, 22 deletions
diff --git a/fs_mgr/fs_mgr.cpp b/fs_mgr/fs_mgr.cpp
index 8c0c1efe3..835a3e7f6 100644
--- a/fs_mgr/fs_mgr.cpp
+++ b/fs_mgr/fs_mgr.cpp
@@ -40,6 +40,7 @@
#include <functional>
#include <map>
#include <memory>
+#include <numeric>
#include <string>
#include <string_view>
#include <thread>
@@ -1553,7 +1554,9 @@ MountAllResult fs_mgr_mount_all(Fstab* fstab, int mount_mode) {
fs_mgr_set_blk_ro(attempted_entry.blk_device, false);
if (!call_vdc({"cryptfs", "encryptFstab", attempted_entry.blk_device,
attempted_entry.mount_point, wiped ? "true" : "false",
- attempted_entry.fs_type, attempted_entry.zoned_device},
+ attempted_entry.fs_type,
+ attempted_entry.fs_mgr_flags.is_zoned ? "true" : "false",
+ android::base::Join(attempted_entry.user_devices, ' ')},
nullptr)) {
LERROR << "Encryption failed";
set_type_property(encryptable);
@@ -1596,7 +1599,9 @@ MountAllResult fs_mgr_mount_all(Fstab* fstab, int mount_mode) {
if (!call_vdc({"cryptfs", "encryptFstab", current_entry.blk_device,
current_entry.mount_point, "true" /* shouldFormat */,
- current_entry.fs_type, current_entry.zoned_device},
+ current_entry.fs_type,
+ current_entry.fs_mgr_flags.is_zoned ? "true" : "false",
+ android::base::Join(current_entry.user_devices, ' ')},
nullptr)) {
LERROR << "Encryption failed";
} else {
@@ -1621,7 +1626,9 @@ MountAllResult fs_mgr_mount_all(Fstab* fstab, int mount_mode) {
if (mount_errno != EBUSY && mount_errno != EACCES &&
should_use_metadata_encryption(attempted_entry)) {
if (!call_vdc({"cryptfs", "mountFstab", attempted_entry.blk_device,
- attempted_entry.mount_point, attempted_entry.zoned_device},
+ attempted_entry.mount_point,
+ current_entry.fs_mgr_flags.is_zoned ? "true" : "false",
+ android::base::Join(current_entry.user_devices, ' ')},
nullptr)) {
++error_count;
} else if (current_entry.mount_point == "/data") {
diff --git a/fs_mgr/fs_mgr_format.cpp b/fs_mgr/fs_mgr_format.cpp
index 8e7615010..0dde1d374 100644
--- a/fs_mgr/fs_mgr_format.cpp
+++ b/fs_mgr/fs_mgr_format.cpp
@@ -125,7 +125,8 @@ static int format_ext4(const std::string& fs_blkdev, const std::string& fs_mnt_p
}
static int format_f2fs(const std::string& fs_blkdev, uint64_t dev_sz, bool needs_projid,
- bool needs_casefold, bool fs_compress, const std::string& zoned_device) {
+ bool needs_casefold, bool fs_compress, bool is_zoned,
+ const std::vector<std::string>& user_devices) {
if (!dev_sz) {
int rc = get_dev_sz(fs_blkdev, &dev_sz);
if (rc) {
@@ -159,16 +160,21 @@ static int format_f2fs(const std::string& fs_blkdev, uint64_t dev_sz, bool needs
args.push_back(block_size.c_str());
args.push_back("-b");
args.push_back(block_size.c_str());
- if (!zoned_device.empty()) {
- args.push_back("-c");
- args.push_back(zoned_device.c_str());
+
+ if (is_zoned) {
args.push_back("-m");
+ }
+ for (auto& device : user_devices) {
+ args.push_back("-c");
+ args.push_back(device.c_str());
+ }
+
+ if (user_devices.empty()) {
args.push_back(fs_blkdev.c_str());
+ args.push_back(size_str.c_str());
} else {
args.push_back(fs_blkdev.c_str());
- args.push_back(size_str.c_str());
}
-
return logwrap_fork_execvp(args.size(), args.data(), nullptr, false, LOG_KLOG, false, nullptr);
}
@@ -184,7 +190,8 @@ int fs_mgr_do_format(const FstabEntry& entry) {
if (entry.fs_type == "f2fs") {
return format_f2fs(entry.blk_device, entry.length, needs_projid, needs_casefold,
- entry.fs_mgr_flags.fs_compress, entry.zoned_device);
+ entry.fs_mgr_flags.fs_compress, entry.fs_mgr_flags.is_zoned,
+ entry.user_devices);
} else if (entry.fs_type == "ext4") {
return format_ext4(entry.blk_device, entry.mount_point, needs_projid,
entry.fs_mgr_flags.ext_meta_csum);
diff --git a/fs_mgr/libfstab/fstab.cpp b/fs_mgr/libfstab/fstab.cpp
index 6273ee2e8..f00e0dc26 100644
--- a/fs_mgr/libfstab/fstab.cpp
+++ b/fs_mgr/libfstab/fstab.cpp
@@ -147,6 +147,29 @@ void ParseMountFlags(const std::string& flags, FstabEntry* entry) {
entry->fs_options = std::move(fs_options);
}
+void ParseUserDevices(const std::string& arg, FstabEntry* entry) {
+ auto param = Split(arg, ":");
+ if (param.size() != 2) {
+ LWARNING << "Warning: device= malformed: " << arg;
+ return;
+ }
+
+ if (access(param[1].c_str(), F_OK) != 0) {
+ LWARNING << "Warning: device does not exist : " << param[1];
+ return;
+ }
+
+ if (param[0] == "zoned") {
+ // atgc in f2fs does not support a zoned device
+ auto options = Split(entry->fs_options, ",");
+ options.erase(std::remove(options.begin(), options.end(), "atgc"), options.end());
+ entry->fs_options = android::base::Join(options, ",");
+ LINFO << "Removed ATGC in fs_options as " << entry->fs_options << " for zoned device";
+ entry->fs_mgr_flags.is_zoned = true;
+ }
+ entry->user_devices.push_back(param[1]);
+}
+
bool ParseFsMgrFlags(const std::string& flags, FstabEntry* entry) {
for (const auto& flag : Split(flags, ",")) {
if (flag.empty() || flag == "defaults") continue;
@@ -311,17 +334,8 @@ bool ParseFsMgrFlags(const std::string& flags, FstabEntry* entry) {
if (!ParseByteCount(arg, &entry->zram_backingdev_size)) {
LWARNING << "Warning: zram_backingdev_size= flag malformed: " << arg;
}
- } else if (flag == "zoned_device") {
- if (access("/dev/block/by-name/zoned_device", F_OK) == 0) {
- entry->zoned_device = "/dev/block/by-name/zoned_device";
-
- // atgc in f2fs does not support a zoned device
- auto options = Split(entry->fs_options, ",");
- options.erase(std::remove(options.begin(), options.end(), "atgc"), options.end());
- entry->fs_options = android::base::Join(options, ",");
- LINFO << "Removed ATGC in fs_options as " << entry->fs_options
- << " for zoned device=" << entry->zoned_device;
- }
+ } else if (StartsWith(flag, "device=")) {
+ ParseUserDevices(arg, entry);
} else {
LWARNING << "Warning: unknown flag: " << flag;
}
diff --git a/fs_mgr/libfstab/include/fstab/fstab.h b/fs_mgr/libfstab/include/fstab/fstab.h
index dea723831..1696daff0 100644
--- a/fs_mgr/libfstab/include/fstab/fstab.h
+++ b/fs_mgr/libfstab/include/fstab/fstab.h
@@ -32,7 +32,7 @@ namespace fs_mgr {
struct FstabEntry {
std::string blk_device;
- std::string zoned_device;
+ std::vector<std::string> user_devices;
std::string logical_partition_name;
std::string mount_point;
std::string fs_type;
@@ -85,6 +85,7 @@ struct FstabEntry {
bool ext_meta_csum : 1;
bool fs_compress : 1;
bool overlayfs_remove_missing_lowerdir : 1;
+ bool is_zoned : 1;
} fs_mgr_flags = {};
bool is_encryptable() const { return fs_mgr_flags.crypt; }