summaryrefslogtreecommitdiff
path: root/fs_mgr
diff options
context:
space:
mode:
Diffstat (limited to 'fs_mgr')
-rw-r--r--fs_mgr/fs_mgr.cpp2
-rw-r--r--fs_mgr/fs_mgr_overlayfs.cpp21
-rw-r--r--fs_mgr/libdm/Android.bp1
-rw-r--r--fs_mgr/libfiemap/fiemap_writer.cpp2
-rw-r--r--fs_mgr/libfiemap/split_fiemap_writer.cpp2
-rw-r--r--fs_mgr/libfiemap/utility.cpp3
-rw-r--r--fs_mgr/libfs_avb/avb_ops.cpp36
-rw-r--r--fs_mgr/libfs_avb/fs_avb.cpp6
-rw-r--r--fs_mgr/libfs_avb/tests/util_test.cpp6
-rw-r--r--fs_mgr/liblp/builder_test.cpp2
-rw-r--r--fs_mgr/liblp/device_test.cpp2
-rw-r--r--fs_mgr/liblp/partition_opener.cpp2
-rw-r--r--fs_mgr/liblp/reader.cpp4
-rw-r--r--fs_mgr/liblp/writer.cpp4
-rw-r--r--fs_mgr/libsnapshot/Android.bp33
-rw-r--r--fs_mgr/libsnapshot/include/libsnapshot/snapshot.h5
-rw-r--r--fs_mgr/libsnapshot/snapshot.cpp7
-rw-r--r--fs_mgr/libsnapshot/snapshot_fuzz.cpp2
-rw-r--r--fs_mgr/libsnapshot/snapshot_fuzz_utils.h4
-rw-r--r--fs_mgr/libsnapshot/snapshot_metadata_updater.cpp9
-rw-r--r--fs_mgr/libsnapshot/snapuserd.cpp126
-rwxr-xr-xfs_mgr/tests/adb-remount-test.sh194
22 files changed, 338 insertions, 135 deletions
diff --git a/fs_mgr/fs_mgr.cpp b/fs_mgr/fs_mgr.cpp
index 0ae57870fa..88bb2344c0 100644
--- a/fs_mgr/fs_mgr.cpp
+++ b/fs_mgr/fs_mgr.cpp
@@ -607,7 +607,7 @@ static void tune_metadata_csum(const std::string& blk_device, const FstabEntry&
LINFO << "Enabling ext4 metadata_csum on " << blk_device;
- // requires to give last_fsck_time to current to avoid insane time.
+ // 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",
"-T", "now", blk_device.c_str()};
diff --git a/fs_mgr/fs_mgr_overlayfs.cpp b/fs_mgr/fs_mgr_overlayfs.cpp
index 1fa1aa1042..a7704de696 100644
--- a/fs_mgr/fs_mgr_overlayfs.cpp
+++ b/fs_mgr/fs_mgr_overlayfs.cpp
@@ -809,15 +809,26 @@ bool fs_mgr_overlayfs_mount_scratch(const std::string& device_path, const std::s
entry.fs_type = mnt_type;
if ((mnt_type == "f2fs") && !f2fs) entry.fs_type = "ext4";
if ((mnt_type == "ext4") && !ext4) entry.fs_type = "f2fs";
- entry.flags = MS_NOATIME;
- if (readonly) {
- entry.flags |= MS_RDONLY;
- } else {
+ entry.flags = MS_NOATIME | MS_RDONLY;
+ auto mounted = true;
+ if (!readonly) {
+ if (entry.fs_type == "ext4") {
+ // check if ext4 de-dupe
+ entry.flags |= MS_RDONLY;
+ auto save_errno = errno;
+ mounted = fs_mgr_do_mount_one(entry) == 0;
+ if (mounted) {
+ mounted = !fs_mgr_has_shared_blocks(entry.mount_point, entry.blk_device);
+ fs_mgr_overlayfs_umount_scratch();
+ }
+ errno = save_errno;
+ }
+ entry.flags &= ~MS_RDONLY;
fs_mgr_set_blk_ro(device_path, false);
}
entry.fs_mgr_flags.check = true;
auto save_errno = errno;
- auto mounted = fs_mgr_do_mount_one(entry) == 0;
+ if (mounted) mounted = fs_mgr_do_mount_one(entry) == 0;
if (!mounted) {
if ((entry.fs_type == "f2fs") && ext4) {
entry.fs_type = "ext4";
diff --git a/fs_mgr/libdm/Android.bp b/fs_mgr/libdm/Android.bp
index 58241b3f83..e4252845c5 100644
--- a/fs_mgr/libdm/Android.bp
+++ b/fs_mgr/libdm/Android.bp
@@ -42,6 +42,7 @@ cc_library_static {
enabled: false,
},
},
+ ramdisk_available: true,
}
filegroup {
diff --git a/fs_mgr/libfiemap/fiemap_writer.cpp b/fs_mgr/libfiemap/fiemap_writer.cpp
index 4dd4bcc14b..621031ada6 100644
--- a/fs_mgr/libfiemap/fiemap_writer.cpp
+++ b/fs_mgr/libfiemap/fiemap_writer.cpp
@@ -45,7 +45,7 @@ namespace fiemap {
using namespace android::dm;
-// We cap the maximum number of extents as a sanity measure.
+// We cap the maximum number of extents as a robustness measure.
static constexpr uint32_t kMaxExtents = 50000;
// TODO: Fallback to using fibmap if FIEMAP_EXTENT_MERGED is set.
diff --git a/fs_mgr/libfiemap/split_fiemap_writer.cpp b/fs_mgr/libfiemap/split_fiemap_writer.cpp
index 12c73979d5..36bb3dfeee 100644
--- a/fs_mgr/libfiemap/split_fiemap_writer.cpp
+++ b/fs_mgr/libfiemap/split_fiemap_writer.cpp
@@ -266,7 +266,7 @@ bool SplitFiemap::Write(const void* data, uint64_t bytes) {
cursor_file_pos_ += bytes_to_write;
}
- // If we've reached the end of the current file, close it for sanity.
+ // If we've reached the end of the current file, close it.
if (cursor_file_pos_ == file->size()) {
cursor_fd_ = {};
}
diff --git a/fs_mgr/libfiemap/utility.cpp b/fs_mgr/libfiemap/utility.cpp
index bbb0510faf..c1898556e4 100644
--- a/fs_mgr/libfiemap/utility.cpp
+++ b/fs_mgr/libfiemap/utility.cpp
@@ -139,8 +139,7 @@ bool BlockDeviceToName(uint32_t major, uint32_t minor, std::string* bdev_name) {
}
*bdev_name = ::android::base::Basename(sysfs_bdev);
- // Paranoid sanity check to make sure we just didn't get the
- // input in return as-is.
+ // Check that the symlink doesn't point to itself.
if (sysfs_bdev == *bdev_name) {
LOG(ERROR) << "Malformed symlink for block device: " << sysfs_bdev;
return false;
diff --git a/fs_mgr/libfs_avb/avb_ops.cpp b/fs_mgr/libfs_avb/avb_ops.cpp
index c192bf572e..46072bb701 100644
--- a/fs_mgr/libfs_avb/avb_ops.cpp
+++ b/fs_mgr/libfs_avb/avb_ops.cpp
@@ -52,16 +52,16 @@ static AvbIOResult read_from_partition(AvbOps* ops, const char* partition, int64
partition, offset, num_bytes, buffer, out_num_read);
}
-static AvbIOResult dummy_read_rollback_index(AvbOps* ops ATTRIBUTE_UNUSED,
- size_t rollback_index_location ATTRIBUTE_UNUSED,
- uint64_t* out_rollback_index) {
+static AvbIOResult no_op_read_rollback_index(AvbOps* ops ATTRIBUTE_UNUSED,
+ size_t rollback_index_location ATTRIBUTE_UNUSED,
+ uint64_t* out_rollback_index) {
// rollback_index has been checked in bootloader phase.
// In user-space, returns the smallest value 0 to pass the check.
*out_rollback_index = 0;
return AVB_IO_RESULT_OK;
}
-static AvbIOResult dummy_validate_vbmeta_public_key(
+static AvbIOResult no_op_validate_vbmeta_public_key(
AvbOps* ops ATTRIBUTE_UNUSED, const uint8_t* public_key_data ATTRIBUTE_UNUSED,
size_t public_key_length ATTRIBUTE_UNUSED,
const uint8_t* public_key_metadata ATTRIBUTE_UNUSED,
@@ -76,8 +76,8 @@ static AvbIOResult dummy_validate_vbmeta_public_key(
return AVB_IO_RESULT_OK;
}
-static AvbIOResult dummy_read_is_device_unlocked(AvbOps* ops ATTRIBUTE_UNUSED,
- bool* out_is_unlocked) {
+static AvbIOResult no_op_read_is_device_unlocked(AvbOps* ops ATTRIBUTE_UNUSED,
+ bool* out_is_unlocked) {
// The function is for bootloader to update the value into
// androidboot.vbmeta.device_state in kernel cmdline.
// In user-space, returns true as we don't need to update it anymore.
@@ -85,9 +85,9 @@ static AvbIOResult dummy_read_is_device_unlocked(AvbOps* ops ATTRIBUTE_UNUSED,
return AVB_IO_RESULT_OK;
}
-static AvbIOResult dummy_get_unique_guid_for_partition(AvbOps* ops ATTRIBUTE_UNUSED,
- const char* partition ATTRIBUTE_UNUSED,
- char* guid_buf, size_t guid_buf_size) {
+static AvbIOResult no_op_get_unique_guid_for_partition(AvbOps* ops ATTRIBUTE_UNUSED,
+ const char* partition ATTRIBUTE_UNUSED,
+ char* guid_buf, size_t guid_buf_size) {
// The function is for bootloader to set the correct UUID
// for a given partition in kernel cmdline.
// In user-space, returns a faking one as we don't need to update
@@ -96,9 +96,9 @@ static AvbIOResult dummy_get_unique_guid_for_partition(AvbOps* ops ATTRIBUTE_UNU
return AVB_IO_RESULT_OK;
}
-static AvbIOResult dummy_get_size_of_partition(AvbOps* ops ATTRIBUTE_UNUSED,
- const char* partition ATTRIBUTE_UNUSED,
- uint64_t* out_size_num_byte) {
+static AvbIOResult no_op_get_size_of_partition(AvbOps* ops ATTRIBUTE_UNUSED,
+ const char* partition ATTRIBUTE_UNUSED,
+ uint64_t* out_size_num_byte) {
// The function is for bootloader to load entire content of AVB HASH partitions.
// In user-space, returns 0 as we only need to set up AVB HASHTHREE partitions.
*out_size_num_byte = 0;
@@ -123,15 +123,15 @@ FsManagerAvbOps::FsManagerAvbOps() {
// We only need to provide the implementation of read_from_partition()
// operation since that's all what is being used by the avb_slot_verify().
// Other I/O operations are only required in bootloader but not in
- // user-space so we set them as dummy operations. Also zero the entire
+ // user-space so we set them as no-op operations. Also zero the entire
// struct so operations added in the future will be set to NULL.
memset(&avb_ops_, 0, sizeof(AvbOps));
avb_ops_.read_from_partition = read_from_partition;
- avb_ops_.read_rollback_index = dummy_read_rollback_index;
- avb_ops_.validate_vbmeta_public_key = dummy_validate_vbmeta_public_key;
- avb_ops_.read_is_device_unlocked = dummy_read_is_device_unlocked;
- avb_ops_.get_unique_guid_for_partition = dummy_get_unique_guid_for_partition;
- avb_ops_.get_size_of_partition = dummy_get_size_of_partition;
+ avb_ops_.read_rollback_index = no_op_read_rollback_index;
+ avb_ops_.validate_vbmeta_public_key = no_op_validate_vbmeta_public_key;
+ avb_ops_.read_is_device_unlocked = no_op_read_is_device_unlocked;
+ avb_ops_.get_unique_guid_for_partition = no_op_get_unique_guid_for_partition;
+ avb_ops_.get_size_of_partition = no_op_get_size_of_partition;
// Sets user_data for GetInstanceFromAvbOps() to convert it back to FsManagerAvbOps.
avb_ops_.user_data = this;
diff --git a/fs_mgr/libfs_avb/fs_avb.cpp b/fs_mgr/libfs_avb/fs_avb.cpp
index 5d504ab0dc..49333a13b2 100644
--- a/fs_mgr/libfs_avb/fs_avb.cpp
+++ b/fs_mgr/libfs_avb/fs_avb.cpp
@@ -226,7 +226,7 @@ AvbUniquePtr AvbHandle::LoadAndVerifyVbmeta(
return nullptr;
}
- // Sanity check here because we have to use vbmeta_images_[0] below.
+ // Validity check here because we have to use vbmeta_images_[0] below.
if (avb_handle->vbmeta_images_.size() < 1) {
LERROR << "LoadAndVerifyVbmetaByPartition failed, no vbmeta loaded";
return nullptr;
@@ -405,11 +405,11 @@ AvbUniquePtr AvbHandle::Open() {
// - AVB_SLOT_VERIFY_RESULT_ERROR_VERIFICATION (UNLOCKED only).
// Might occur in either the top-level vbmeta or a chained vbmeta.
// - AVB_SLOT_VERIFY_RESULT_ERROR_PUBLIC_KEY_REJECTED (UNLOCKED only).
- // Could only occur in a chained vbmeta. Because we have *dummy* operations in
+ // Could only occur in a chained vbmeta. Because we have *no-op* operations in
// FsManagerAvbOps such that avb_ops->validate_vbmeta_public_key() used to validate
// the public key of the top-level vbmeta always pass in userspace here.
//
- // The following verify result won't happen, because the *dummy* operation
+ // The following verify result won't happen, because the *no-op* operation
// avb_ops->read_rollback_index() always returns the minimum value zero. So rollbacked
// vbmeta images, which should be caught in the bootloader stage, won't be detected here.
// - AVB_SLOT_VERIFY_RESULT_ERROR_ROLLBACK_INDEX
diff --git a/fs_mgr/libfs_avb/tests/util_test.cpp b/fs_mgr/libfs_avb/tests/util_test.cpp
index 5c388aaeb3..a52a00d276 100644
--- a/fs_mgr/libfs_avb/tests/util_test.cpp
+++ b/fs_mgr/libfs_avb/tests/util_test.cpp
@@ -222,7 +222,7 @@ TEST(BasicUtilTest, ListFiles) {
base::FilePath test_dir;
ASSERT_TRUE(base::CreateTemporaryDirInDir(tmp_dir, "list-file-tests.", &test_dir));
- // Generates dummy files to list.
+ // Generates test files to list.
base::FilePath file_path_1 = test_dir.Append("1.txt");
ASSERT_TRUE(base::WriteFile(file_path_1, "1", 1));
base::FilePath file_path_2 = test_dir.Append("2.txt");
@@ -253,7 +253,7 @@ TEST(BasicUtilTest, ListFilesShouldDiscardSymlink) {
base::FilePath test_dir;
ASSERT_TRUE(base::CreateTemporaryDirInDir(tmp_dir, "list-file-tests.", &test_dir));
- // Generates dummy files to list.
+ // Generates test files to list.
base::FilePath file_path_1 = test_dir.Append("1.txt");
ASSERT_TRUE(base::WriteFile(file_path_1, "1", 1));
base::FilePath file_path_2 = test_dir.Append("2.txt");
@@ -281,7 +281,7 @@ TEST(BasicUtilTest, ListFilesOpenDirFailure) {
base::FilePath tmp_dir;
ASSERT_TRUE(GetTempDir(&tmp_dir));
- // Generates dummy files to list.
+ // Generates test files to list.
base::FilePath no_such_dir = tmp_dir.Append("not_such_dir");
auto fail = ListFiles(no_such_dir.value());
diff --git a/fs_mgr/liblp/builder_test.cpp b/fs_mgr/liblp/builder_test.cpp
index a21e09e4f2..e4b617a51b 100644
--- a/fs_mgr/liblp/builder_test.cpp
+++ b/fs_mgr/liblp/builder_test.cpp
@@ -234,7 +234,7 @@ TEST_F(BuilderTest, InternalPartitionAlignment) {
EXPECT_EQ(lba, aligned_lba);
}
- // Sanity check one extent.
+ // Check one extent.
EXPECT_EQ(exported->extents.back().target_data, 3072);
}
diff --git a/fs_mgr/liblp/device_test.cpp b/fs_mgr/liblp/device_test.cpp
index 6af9d94db7..236fd8dd3b 100644
--- a/fs_mgr/liblp/device_test.cpp
+++ b/fs_mgr/liblp/device_test.cpp
@@ -47,7 +47,7 @@ TEST_F(DeviceTest, BlockDeviceInfo) {
BlockDeviceInfo device_info;
ASSERT_TRUE(opener.GetInfo(fs_mgr_get_super_partition_name(), &device_info));
- // Sanity check that the device doesn't give us some weird inefficient
+ // Check that the device doesn't give us some weird inefficient
// alignment.
EXPECT_EQ(device_info.alignment % LP_SECTOR_SIZE, 0);
EXPECT_EQ(device_info.logical_block_size % LP_SECTOR_SIZE, 0);
diff --git a/fs_mgr/liblp/partition_opener.cpp b/fs_mgr/liblp/partition_opener.cpp
index 1d4db85250..3d3dde6f2f 100644
--- a/fs_mgr/liblp/partition_opener.cpp
+++ b/fs_mgr/liblp/partition_opener.cpp
@@ -49,7 +49,7 @@ std::string GetPartitionAbsolutePath(const std::string& path) {
// Dynamic System Update is installed to an sdcard, which won't be in
// the boot device list.
//
- // We whitelist because most devices in /dev/block are not valid for
+ // mmcblk* is allowed because most devices in /dev/block are not valid for
// storing fiemaps.
if (android::base::StartsWith(path, "mmcblk")) {
return "/dev/block/" + path;
diff --git a/fs_mgr/liblp/reader.cpp b/fs_mgr/liblp/reader.cpp
index e6fd9f72a4..24ccc0f9de 100644
--- a/fs_mgr/liblp/reader.cpp
+++ b/fs_mgr/liblp/reader.cpp
@@ -174,7 +174,7 @@ static bool ReadMetadataHeader(Reader* reader, LpMetadata* metadata) {
return false;
}
- // Do basic sanity checks before computing the checksum.
+ // Do basic validity checks before computing the checksum.
if (header.magic != LP_METADATA_HEADER_MAGIC) {
LERROR << "Logical partition metadata has invalid magic value.";
return false;
@@ -255,7 +255,7 @@ static std::unique_ptr<LpMetadata> ParseMetadata(const LpMetadataGeometry& geome
LpMetadataHeader& header = metadata->header;
- // Sanity check the table size.
+ // Check the table size.
if (header.tables_size > geometry.metadata_max_size) {
LERROR << "Invalid partition metadata header table size.";
return nullptr;
diff --git a/fs_mgr/liblp/writer.cpp b/fs_mgr/liblp/writer.cpp
index 8bf1ee9232..2708efa156 100644
--- a/fs_mgr/liblp/writer.cpp
+++ b/fs_mgr/liblp/writer.cpp
@@ -81,8 +81,8 @@ std::string SerializeMetadata(const LpMetadata& input) {
return header_blob + tables;
}
-// Perform sanity checks so we don't accidentally overwrite valid metadata
-// with potentially invalid metadata, or random partition data with metadata.
+// Perform checks so we don't accidentally overwrite valid metadata with
+// potentially invalid metadata, or random partition data with metadata.
static bool ValidateAndSerializeMetadata([[maybe_unused]] const IPartitionOpener& opener,
const LpMetadata& metadata, const std::string& slot_suffix,
std::string* blob) {
diff --git a/fs_mgr/libsnapshot/Android.bp b/fs_mgr/libsnapshot/Android.bp
index 95301ff71a..eaef180377 100644
--- a/fs_mgr/libsnapshot/Android.bp
+++ b/fs_mgr/libsnapshot/Android.bp
@@ -310,3 +310,36 @@ cc_test {
auto_gen_config: true,
require_root: true,
}
+
+cc_defaults {
+ name: "snapuserd_defaults",
+ srcs: [
+ "snapuserd.cpp",
+ ],
+
+ cflags: [
+ "-Wall",
+ "-Werror"
+ ],
+
+ static_libs: [
+ "libbase",
+ "liblog",
+ "libdm",
+ ],
+}
+
+cc_binary {
+ name: "snapuserd",
+ defaults: ["snapuserd_defaults"],
+}
+
+cc_binary {
+ name: "snapuserd_ramdisk",
+ stem: "snapuserd",
+ defaults: ["snapuserd_defaults"],
+
+ ramdisk: true,
+ static_executable: true,
+ system_shared_libs: [],
+}
diff --git a/fs_mgr/libsnapshot/include/libsnapshot/snapshot.h b/fs_mgr/libsnapshot/include/libsnapshot/snapshot.h
index 3c2c77683b..a4a31507ee 100644
--- a/fs_mgr/libsnapshot/include/libsnapshot/snapshot.h
+++ b/fs_mgr/libsnapshot/include/libsnapshot/snapshot.h
@@ -553,9 +553,8 @@ class SnapshotManager final : public ISnapshotManager {
// This should only be called in recovery.
bool UnmapAllPartitions();
- // Sanity check no snapshot overflows. Note that this returns false negatives if the snapshot
- // overflows, then is remapped and not written afterwards. Hence, the function may only serve
- // as a sanity check.
+ // Check no snapshot overflows. Note that this returns false negatives if the snapshot
+ // overflows, then is remapped and not written afterwards.
bool EnsureNoOverflowSnapshot(LockedFile* lock);
enum class Slot { Unknown, Source, Target };
diff --git a/fs_mgr/libsnapshot/snapshot.cpp b/fs_mgr/libsnapshot/snapshot.cpp
index 7488bdaca8..b49f99ea45 100644
--- a/fs_mgr/libsnapshot/snapshot.cpp
+++ b/fs_mgr/libsnapshot/snapshot.cpp
@@ -300,9 +300,9 @@ bool SnapshotManager::CreateSnapshot(LockedFile* lock, SnapshotStatus* status) {
LOG(ERROR) << "SnapshotStatus has no name.";
return false;
}
- // Sanity check these sizes. Like liblp, we guarantee the partition size
- // is respected, which means it has to be sector-aligned. (This guarantee
- // is useful for locating avb footers correctly). The COW file size, however,
+ // Check these sizes. Like liblp, we guarantee the partition size is
+ // respected, which means it has to be sector-aligned. (This guarantee is
+ // useful for locating avb footers correctly). The COW file size, however,
// can be arbitrarily larger than specified, so we can safely round it up.
if (status->device_size() % kSectorSize != 0) {
LOG(ERROR) << "Snapshot " << status->name()
@@ -351,7 +351,6 @@ Return SnapshotManager::CreateCowImage(LockedFile* lock, const std::string& name
}
// The COW file size should have been rounded up to the nearest sector in CreateSnapshot.
- // Sanity check this.
if (status.cow_file_size() % kSectorSize != 0) {
LOG(ERROR) << "Snapshot " << name << " COW file size is not a multiple of the sector size: "
<< status.cow_file_size();
diff --git a/fs_mgr/libsnapshot/snapshot_fuzz.cpp b/fs_mgr/libsnapshot/snapshot_fuzz.cpp
index 5b145c31f2..aced3edf58 100644
--- a/fs_mgr/libsnapshot/snapshot_fuzz.cpp
+++ b/fs_mgr/libsnapshot/snapshot_fuzz.cpp
@@ -141,7 +141,7 @@ SNAPSHOT_FUZZ_FUNCTION(RecoveryCreateSnapshotDevicesWithMetadata, CreateResult,
const RecoveryCreateSnapshotDevicesArgs& args) {
std::unique_ptr<AutoDevice> device;
if (args.has_metadata_device_object()) {
- device = std::make_unique<DummyAutoDevice>(args.metadata_mounted());
+ device = std::make_unique<NoOpAutoDevice>(args.metadata_mounted());
}
return snapshot->RecoveryCreateSnapshotDevices(device);
}
diff --git a/fs_mgr/libsnapshot/snapshot_fuzz_utils.h b/fs_mgr/libsnapshot/snapshot_fuzz_utils.h
index fa327b8a74..5319e69de0 100644
--- a/fs_mgr/libsnapshot/snapshot_fuzz_utils.h
+++ b/fs_mgr/libsnapshot/snapshot_fuzz_utils.h
@@ -35,9 +35,9 @@ namespace android::snapshot {
class AutoMemBasedDir;
class SnapshotFuzzDeviceInfo;
-class DummyAutoDevice : public AutoDevice {
+class NoOpAutoDevice : public AutoDevice {
public:
- DummyAutoDevice(bool mounted) : AutoDevice(mounted ? "dummy" : "") {}
+ NoOpAutoDevice(bool mounted) : AutoDevice(mounted ? "no_op" : "") {}
};
struct SnapshotTestModule {
diff --git a/fs_mgr/libsnapshot/snapshot_metadata_updater.cpp b/fs_mgr/libsnapshot/snapshot_metadata_updater.cpp
index 051584c341..17a0c96a89 100644
--- a/fs_mgr/libsnapshot/snapshot_metadata_updater.cpp
+++ b/fs_mgr/libsnapshot/snapshot_metadata_updater.cpp
@@ -39,6 +39,8 @@ namespace snapshot {
SnapshotMetadataUpdater::SnapshotMetadataUpdater(MetadataBuilder* builder, uint32_t target_slot,
const DeltaArchiveManifest& manifest)
: builder_(builder), target_suffix_(SlotSuffixForSlotNumber(target_slot)) {
+ partial_update_ = manifest.partial_update();
+
if (!manifest.has_dynamic_partition_metadata()) {
return;
}
@@ -63,7 +65,6 @@ SnapshotMetadataUpdater::SnapshotMetadataUpdater(MetadataBuilder* builder, uint3
}
}
- partial_update_ = manifest.partial_update();
}
bool SnapshotMetadataUpdater::ShrinkPartitions() const {
@@ -173,9 +174,9 @@ bool SnapshotMetadataUpdater::DeleteGroups() const {
if (iter != groups_.end()) {
continue;
}
- // Update package metadata doesn't have this group. Before deleting it, sanity check that it
- // doesn't have any partitions left. Update metadata shouldn't assign any partitions to this
- // group, so all partitions that originally belong to this group should be moved by
+ // Update package metadata doesn't have this group. Before deleting it, check that it
+ // doesn't have any partitions left. Update metadata shouldn't assign any partitions to
+ // this group, so all partitions that originally belong to this group should be moved by
// MovePartitionsToDefault at this point.
auto existing_partitions_in_group = builder_->ListPartitionsInGroup(existing_group_name);
if (!existing_partitions_in_group.empty()) {
diff --git a/fs_mgr/libsnapshot/snapuserd.cpp b/fs_mgr/libsnapshot/snapuserd.cpp
new file mode 100644
index 0000000000..a6ff4fd046
--- /dev/null
+++ b/fs_mgr/libsnapshot/snapuserd.cpp
@@ -0,0 +1,126 @@
+/*
+ * Copyright (C) 2020 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 <linux/types.h>
+
+#include <android-base/file.h>
+#include <android-base/logging.h>
+#include <android-base/stringprintf.h>
+#include <android-base/unique_fd.h>
+#include <libdm/dm.h>
+
+using android::base::unique_fd;
+
+#define DM_USER_MAP_READ 0
+#define DM_USER_MAP_WRITE 1
+
+struct dm_user_message {
+ __u64 seq;
+ __u64 type;
+ __u64 flags;
+ __u64 sector;
+ __u64 len;
+ __u8 buf[];
+};
+
+using namespace android::dm;
+
+static int daemon_main(const std::string& device) {
+ unique_fd block_fd(open(device.c_str(), O_RDWR));
+ if (block_fd < 0) {
+ PLOG(ERROR) << "Unable to open " << device;
+ return 1;
+ }
+
+ unique_fd ctrl_fd(open("/dev/dm-user", O_RDWR));
+ if (ctrl_fd < 0) {
+ PLOG(ERROR) << "Unable to open /dev/dm-user";
+ return 1;
+ }
+
+ size_t buf_size = 1UL << 16;
+ auto buf = std::make_unique<char>(buf_size);
+
+ /* Just keeps pumping messages between userspace and the kernel. We won't
+ * actually be doing anything, but the sequence numbers line up so it'll at
+ * least make forward progress. */
+ while (true) {
+ struct dm_user_message* msg = (struct dm_user_message*)buf.get();
+
+ memset(buf.get(), 0, buf_size);
+
+ ssize_t readed = read(ctrl_fd.get(), buf.get(), buf_size);
+ if (readed < 0) {
+ PLOG(ERROR) << "Control read failed, trying with more space";
+ buf_size *= 2;
+ buf = std::make_unique<char>(buf_size);
+ continue;
+ }
+
+ LOG(DEBUG) << android::base::StringPrintf("read() from dm-user returned %d bytes:",
+ (int)readed);
+ LOG(DEBUG) << android::base::StringPrintf(" msg->seq: 0x%016llx", msg->seq);
+ LOG(DEBUG) << android::base::StringPrintf(" msg->type: 0x%016llx", msg->type);
+ LOG(DEBUG) << android::base::StringPrintf(" msg->flags: 0x%016llx", msg->flags);
+ LOG(DEBUG) << android::base::StringPrintf(" msg->sector: 0x%016llx", msg->sector);
+ LOG(DEBUG) << android::base::StringPrintf(" msg->len: 0x%016llx", msg->len);
+
+ switch (msg->type) {
+ case DM_USER_MAP_READ: {
+ LOG(DEBUG) << android::base::StringPrintf(
+ "Responding to read of sector %lld with %lld bytes data", msg->sector,
+ msg->len);
+
+ if ((sizeof(*msg) + msg->len) > buf_size) {
+ auto old_buf = std::move(buf);
+ buf_size = sizeof(*msg) + msg->len;
+ buf = std::make_unique<char>(buf_size);
+ memcpy(buf.get(), old_buf.get(), sizeof(*msg));
+ msg = (struct dm_user_message*)buf.get();
+ }
+
+ if (lseek(block_fd.get(), msg->sector * 512, SEEK_SET) < 0) {
+ PLOG(ERROR) << "lseek failed: " << device;
+ return 7;
+ }
+ if (!android::base::ReadFully(block_fd.get(), msg->buf, msg->len)) {
+ PLOG(ERROR) << "read failed: " << device;
+ return 7;
+ }
+
+ if (!android::base::WriteFully(ctrl_fd.get(), buf.get(), sizeof(*msg) + msg->len)) {
+ PLOG(ERROR) << "write control failed";
+ return 3;
+ }
+ break;
+ }
+
+ case DM_USER_MAP_WRITE:
+ abort();
+ break;
+ }
+
+ LOG(DEBUG) << "read() finished, next message";
+ }
+
+ return 0;
+}
+
+int main([[maybe_unused]] int argc, char** argv) {
+ android::base::InitLogging(argv, &android::base::KernelLogger);
+ daemon_main(argv[1]);
+ return 0;
+}
diff --git a/fs_mgr/tests/adb-remount-test.sh b/fs_mgr/tests/adb-remount-test.sh
index 82c42629d8..d56f7f25af 100755
--- a/fs_mgr/tests/adb-remount-test.sh
+++ b/fs_mgr/tests/adb-remount-test.sh
@@ -15,13 +15,17 @@ USAGE="USAGE: `basename ${0}` [--help] [--serial <SerialNumber>] [options]
adb remount tests
---color Dress output with highlighting colors
---help This help
---no-wait-screen Do not wait for display screen to settle
---print-time Report the test duration
---serial Specify device (must if multiple are present)
---wait-adb <duration> adb wait timeout
---wait-fastboot <duration> fastboot wait timeout
+-c --color Dress output with highlighting colors
+-h --help This help
+-D --no-wait-screen Do not wait for display screen to settle
+-t --print-time Report the test duration
+-s --serial Specify device (must if multiple are present)"
+if [ -n "`which timeout`" ]; then
+ USAGE="${USAGE}
+-a --wait-adb <duration> adb wait timeout
+-f --wait-fastboot <duration> fastboot wait timeout"
+fi
+USAGE="${USAGE}
Conditions:
- Must be a userdebug build.
@@ -46,10 +50,10 @@ TAB="`echo | tr '\n' '\t'`"
ESCAPE="`echo | tr '\n' '\033'`"
# A _real_ embedded carriage return character
CR="`echo | tr '\n' '\r'`"
-GREEN="${ESCAPE}[38;5;40m"
-RED="${ESCAPE}[38;5;196m"
-ORANGE="${ESCAPE}[38;5;255:165:0m"
-BLUE="${ESCAPE}[35m"
+GREEN="${ESCAPE}[32m"
+RED="${ESCAPE}[31m"
+YELLOW="${ESCAPE}[33m"
+BLUE="${ESCAPE}[34m"
NORMAL="${ESCAPE}[0m"
TMPDIR=${TMPDIR:-/tmp}
print_time=false
@@ -72,7 +76,7 @@ inFastboot() {
if [ -n "${ANDROID_SERIAL}" ]; then
grep "^${ANDROID_SERIAL}[${SPACE}${TAB}]" > /dev/null
else
- wc -l | grep '^1$' >/dev/null
+ wc -l | grep "^[${SPACE}${TAB}]*1\$" >/dev/null
fi
}
@@ -85,7 +89,7 @@ inAdb() {
if [ -n "${ANDROID_SERIAL}" ]; then
grep "^${ANDROID_SERIAL}[${SPACE}${TAB}]" > /dev/null
else
- wc -l | grep '^1$' >/dev/null
+ wc -l | grep "^[${SPACE}${TAB}]*1\$" >/dev/null
fi
}
@@ -100,7 +104,7 @@ inRecovery() {
grep "^${ANDROID_SERIAL}[${SPACE}${TAB}][${SPACE}${TAB}]*recovery\$" >/dev/null
return ${?}
fi
- if echo "${list}" | wc -l | grep '^1$' >/dev/null; then
+ if echo "${list}" | wc -l | grep "^[${SPACE}${TAB}]*1\$" >/dev/null; then
echo "${list}" |
grep "[${SPACE}${TAB}]recovery\$" >/dev/null
return ${?}
@@ -143,7 +147,7 @@ adb_logcat() {
adb logcat "${@}" </dev/null |
tr -d '\r' |
grep -v 'logd : logdr: UID=' |
- sed -e '${/------- beginning of kernel/d}' -e 's/^[0-1][0-9]-[0-3][0-9] //'
+ sed -e '${ /------- beginning of kernel/d }' -e 's/^[0-1][0-9]-[0-3][0-9] //'
}
[ "USAGE: avc_check >/dev/stderr
@@ -160,7 +164,7 @@ avc_check() {
if [ -z "${L}" ]; then
return
fi
- echo "${ORANGE}[ WARNING ]${NORMAL} unlabeled sepolicy violations:" >&2
+ echo "${YELLOW}[ WARNING ]${NORMAL} unlabeled sepolicy violations:" >&2
echo "${L}" | sed "s/^/${INDENT}/" >&2
}
@@ -284,7 +288,7 @@ adb_wait() {
local start=`date +%s`
local duration=
local ret
- if [ -n "${1}" ]; then
+ if [ -n "${1}" -a -n "`which timeout`" ]; then
USB_DEVICE=`usb_devnum --next`
duration=`format_duration ${1}`
echo -n ". . . waiting ${duration}" ${ANDROID_SERIAL} ${USB_ADDRESS} ${USB_DEVICE} "${CR}"
@@ -299,7 +303,7 @@ adb_wait() {
if [ 0 = ${ret} -a -n "${ACTIVE_SLOT}" ]; then
local active_slot=`get_active_slot`
if [ X"${ACTIVE_SLOT}" != X"${active_slot}" ]; then
- echo "${ORANGE}[ WARNING ]${NORMAL} Active slot changed from ${ACTIVE_SLOT} to ${active_slot}" >&2
+ echo "${YELLOW}[ WARNING ]${NORMAL} Active slot changed from ${ACTIVE_SLOT} to ${active_slot}" >&2
fi
fi
local end=`date +%s`
@@ -359,18 +363,22 @@ usb_status() {
echo "(In adb mode `adb_user`)"
else
echo "(USB stack borken for ${USB_ADDRESS})"
- USB_DEVICE=`usb_devnum`
- if [ -n "${USB_DEVICE}" ]; then
- echo "# lsusb -v -s ${USB_DEVICE#dev}"
- local D=`lsusb -v -s ${USB_DEVICE#dev} 2>&1`
- if [ -n "${D}" ]; then
- echo "${D}"
- else
- lsusb -v
+ if [ -n "`which usb_devnum`" ]; then
+ USB_DEVICE=`usb_devnum`
+ if [ -n "`which lsusb`" ]; then
+ if [ -n "${USB_DEVICE}" ]; then
+ echo "# lsusb -v -s ${USB_DEVICE#dev}"
+ local D=`lsusb -v -s ${USB_DEVICE#dev} 2>&1`
+ if [ -n "${D}" ]; then
+ echo "${D}"
+ else
+ lsusb -v
+ fi
+ else
+ echo "# lsusb -v (expected device missing)"
+ lsusb -v
+ fi
fi
- else
- echo "# lsusb -v (expected device missing)"
- lsusb -v
fi >&2
fi
}
@@ -382,7 +390,7 @@ fastboot_wait() {
local ret
# fastboot has no wait-for-device, but it does an automatic
# wait and requires (even a nonsensical) command to do so.
- if [ -n "${1}" ]; then
+ if [ -n "${1}" -a -n "`which timeout`" ]; then
USB_DEVICE=`usb_devnum --next`
echo -n ". . . waiting `format_duration ${1}`" ${ANDROID_SERIAL} ${USB_ADDRESS} ${USB_DEVICE} "${CR}"
timeout --preserve-status --signal=KILL ${1} fastboot wait-for-device >/dev/null 2>/dev/null
@@ -398,7 +406,7 @@ fastboot_wait() {
if [ 0 = ${ret} -a -n "${ACTIVE_SLOT}" ]; then
local active_slot=`get_active_slot`
if [ X"${ACTIVE_SLOT}" != X"${active_slot}" ]; then
- echo "${ORANGE}[ WARNING ]${NORMAL} Active slot changed from ${ACTIVE_SLOT} to ${active_slot}"
+ echo "${YELLOW}[ WARNING ]${NORMAL} Active slot changed from ${ACTIVE_SLOT} to ${active_slot}"
fi >&2
fi
return ${ret}
@@ -409,7 +417,7 @@ fastboot_wait() {
Returns: waits until the device has returned for recovery or optional timeout" ]
recovery_wait() {
local ret
- if [ -n "${1}" ]; then
+ if [ -n "${1}" -a -n "`which timeout`" ]; then
USB_DEVICE=`usb_devnum --next`
echo -n ". . . waiting `format_duration ${1}`" ${ANDROID_SERIAL} ${USB_ADDRESS} ${USB_DEVICE} "${CR}"
timeout --preserve-status --signal=KILL ${1} adb wait-for-recovery 2>/dev/null
@@ -423,7 +431,7 @@ recovery_wait() {
if [ 0 = ${ret} -a -n "${ACTIVE_SLOT}" ]; then
local active_slot=`get_active_slot`
if [ X"${ACTIVE_SLOT}" != X"${active_slot}" ]; then
- echo "${ORANGE}[ WARNING ]${NORMAL} Active slot changed from ${ACTIVE_SLOT} to ${active_slot}"
+ echo "${YELLOW}[ WARNING ]${NORMAL} Active slot changed from ${ACTIVE_SLOT} to ${active_slot}"
fi >&2
fi
return ${ret}
@@ -732,6 +740,7 @@ skip_administrative_mounts() {
grep -v \
-e "^\(overlay\|tmpfs\|none\|sysfs\|proc\|selinuxfs\|debugfs\|bpf\) " \
-e "^\(binfmt_misc\|cg2_bpf\|pstore\|tracefs\|adb\|mtp\|ptp\|devpts\) " \
+ -e "^\(ramdumpfs\) " \
-e " functionfs " \
-e "^\(/data/media\|/dev/block/loop[0-9]*\) " \
-e "^rootfs / rootfs rw," \
@@ -753,13 +762,28 @@ skip_unrelated_mounts() {
## MAINLINE
##
-OPTIONS=`getopt --alternative --unquoted \
- --longoptions help,serial:,colour,color,no-colour,no-color \
- --longoptions wait-adb:,wait-fastboot: \
- --longoptions wait-screen,wait-display \
- --longoptions no-wait-screen,no-wait-display \
- --longoptions gtest_print_time,print-time \
- -- "?hs:" ${*}` ||
+HOSTOS=`uname`
+GETOPTS="--alternative --unquoted
+ --longoptions help,serial:,colour,color,no-colour,no-color
+ --longoptions wait-adb:,wait-fastboot:
+ --longoptions wait-screen,wait-display
+ --longoptions no-wait-screen,no-wait-display
+ --longoptions gtest_print_time,print-time
+ --"
+if [ "Darwin" = "${HOSTOS}" ]; then
+ GETOPTS=
+ USAGE="`echo \"${USAGE}\" |
+ sed 's/--color/ /g
+ 1s/--help/-h/
+ s/--help/ /g
+ s/--no-wait-screen/ /g
+ s/--print-time/ /g
+ 1s/--serial/-s/
+ s/--serial/ /g
+ s/--wait-adb/ /g
+ s/--wait-fastboot/ /g'`"
+fi
+OPTIONS=`getopt ${GETOPTS} "?a:cCdDf:hs:t" ${*}` ||
( echo "${USAGE}" >&2 ; false ) ||
die "getopt failure"
set -- ${OPTIONS}
@@ -775,26 +799,26 @@ while [ ${#} -gt 0 ]; do
export ANDROID_SERIAL=${2}
shift
;;
- --color | --colour)
+ -c | --color | --colour)
color=true
;;
- --no-color | --no-colour)
+ -C | --no-color | --no-colour)
color=false
;;
- --no-wait-display | --no-wait-screen)
+ -D | --no-wait-display | --no-wait-screen)
screen_wait=false
;;
- --wait-display | --wait-screen)
+ -d | --wait-display | --wait-screen)
screen_wait=true
;;
- --print-time | --gtest_print_time)
+ -t | --print-time | --gtest_print_time)
print_time=true
;;
- --wait-adb)
+ -a | --wait-adb)
ADB_WAIT=${2}
shift
;;
- --wait-fastboot)
+ -f | --wait-fastboot)
FASTBOOT_WAIT=${2}
shift
;;
@@ -815,7 +839,7 @@ done
if ! ${color}; then
GREEN=""
RED=""
- ORANGE=""
+ YELLOW=""
BLUE=""
NORMAL=""
fi
@@ -827,14 +851,14 @@ fi
inFastboot && die "device in fastboot mode"
inRecovery && die "device in recovery mode"
if ! inAdb; then
- echo "${ORANGE}[ WARNING ]${NORMAL} device not in adb mode" >&2
+ echo "${YELLOW}[ WARNING ]${NORMAL} device not in adb mode" >&2
adb_wait ${ADB_WAIT}
fi
inAdb || die "specified device not in adb mode"
isDebuggable || die "device not a debug build"
enforcing=true
if ! adb_su getenforce </dev/null | grep 'Enforcing' >/dev/null; then
- echo "${ORANGE}[ WARNING ]${NORMAL} device does not have sepolicy in enforcing mode" >&2
+ echo "${YELLOW}[ WARNING ]${NORMAL} device does not have sepolicy in enforcing mode" >&2
enforcing=false
fi
@@ -846,9 +870,13 @@ D=`get_property ro.serialno`
[ -n "${D}" ] || D=`get_property ro.boot.serialno`
[ -z "${D}" -o -n "${ANDROID_SERIAL}" ] || ANDROID_SERIAL=${D}
USB_SERIAL=
-[ -z "${ANDROID_SERIAL}" ] || USB_SERIAL=`find /sys/devices -name serial |
- grep usb |
- xargs -r grep -l ${ANDROID_SERIAL}`
+if [ -n "${ANDROID_SERIAL}" -a "Darwin" != "${HOSTOS}" ]; then
+ USB_SERIAL="`find /sys/devices -name serial | grep usb`"
+ if [ -n "${USB_SERIAL}" ]; then
+ USB_SERIAL=`echo "${USB_SERIAL}" |
+ xargs grep -l ${ANDROID_SERIAL}`
+ fi
+fi
USB_ADDRESS=
if [ -n "${USB_SERIAL}" ]; then
USB_ADDRESS=${USB_SERIAL%/serial}
@@ -860,13 +888,16 @@ fi
BUILD_DESCRIPTION=`get_property ro.build.description`
[ -z "${BUILD_DESCRIPTION}" ] ||
echo "${BLUE}[ INFO ]${NORMAL} ${BUILD_DESCRIPTION}" >&2
+KERNEL_VERSION="`adb_su cat /proc/version </dev/null 2>/dev/null`"
+[ -z "${KERNEL_VERSION}" ] ||
+ echo "${BLUE}[ INFO ]${NORMAL} ${KERNEL_VERSION}" >&2
ACTIVE_SLOT=`get_active_slot`
[ -z "${ACTIVE_SLOT}" ] ||
echo "${BLUE}[ INFO ]${NORMAL} active slot is ${ACTIVE_SLOT}" >&2
# Acquire list of system partitions
-PARTITIONS=`adb_su cat /vendor/etc/fstab* |
+PARTITIONS=`adb_su cat /vendor/etc/fstab* </dev/null |
skip_administrative_mounts |
sed -n "s@^\([^ ${TAB}/][^ ${TAB}/]*\)[ ${TAB}].*[, ${TAB}]ro[, ${TAB}].*@\1@p" |
sort -u |
@@ -903,9 +934,12 @@ adb_sh ls -l /dev/block/by-name/ /dev/block/mapper/ </dev/null 2>/dev/null |
done
# If reboot too soon after fresh flash, could trip device update failure logic
+if ${screen_wait}; then
+ echo "${YELLOW}[ WARNING ]${NORMAL} waiting for screen to come up. Consider --no-wait-screen option" >&2
+fi
if ! wait_for_screen && ${screen_wait}; then
screen_wait=false
- echo "${ORANGE}[ WARNING ]${NORMAL} not healthy, no launcher, skipping wait for screen" >&2
+ echo "${YELLOW}[ WARNING ]${NORMAL} not healthy, no launcher, skipping wait for screen" >&2
fi
# Can we test remount -R command?
@@ -954,7 +988,7 @@ else
adb_su remount -R system </dev/null
err=${?}
if [ "${err}" != 0 ]; then
- echo "${ORANGE}[ WARNING ]${NORMAL} adb shell su root remount -R system = ${err}, likely did not reboot!" >&2
+ echo "${YELLOW}[ WARNING ]${NORMAL} adb shell su root remount -R system = ${err}, likely did not reboot!" >&2
T="-t ${T}"
else
# Rebooted, logcat will be meaningless, and last logcat will likely be clear
@@ -980,7 +1014,7 @@ adb_sh ls -d /sys/module/overlay </dev/null >/dev/null 2>/dev/null ||
adb_sh grep "nodev${TAB}overlay" /proc/filesystems </dev/null >/dev/null 2>/dev/null &&
echo "${GREEN}[ OK ]${NORMAL} overlay module present" >&2 ||
(
- echo "${ORANGE}[ WARNING ]${NORMAL} overlay module not present" >&2 &&
+ echo "${YELLOW}[ WARNING ]${NORMAL} overlay module not present" >&2 &&
false
) ||
overlayfs_supported=false
@@ -989,7 +1023,7 @@ if ${overlayfs_supported}; then
echo "${GREEN}[ OK ]${NORMAL} overlay module supports override_creds" >&2 ||
case `adb_sh uname -r </dev/null` in
4.[456789].* | 4.[1-9][0-9]* | [56789].*)
- echo "${ORANGE}[ WARNING ]${NORMAL} overlay module does not support override_creds" >&2 &&
+ echo "${YELLOW}[ WARNING ]${NORMAL} overlay module does not support override_creds" >&2 &&
overlayfs_supported=false
;;
*)
@@ -1011,14 +1045,14 @@ echo "${GREEN}[ RUN ]${NORMAL} Checking current overlayfs status" >&2
reboot=false
for d in ${OVERLAYFS_BACKING}; do
if adb_sh ls -d /${d}/overlay </dev/null >/dev/null 2>/dev/null; then
- echo "${ORANGE}[ WARNING ]${NORMAL} /${d}/overlay is setup, surgically wiping" >&2
+ echo "${YELLOW}[ WARNING ]${NORMAL} /${d}/overlay is setup, surgically wiping" >&2
adb_sh rm -rf /${d}/overlay </dev/null ||
die "/${d}/overlay wipe"
reboot=true
fi
done
if ${reboot}; then
- echo "${ORANGE}[ WARNING ]${NORMAL} rebooting before test" >&2
+ echo "${YELLOW}[ WARNING ]${NORMAL} rebooting before test" >&2
adb_reboot &&
adb_wait ${ADB_WAIT} ||
die "lost device after reboot after wipe `usb_status`"
@@ -1030,7 +1064,7 @@ D=`adb_sh df -k </dev/null` &&
D=`echo "${D}" | grep -v " /vendor/..*$" | grep "^overlay "` &&
echo "${H}" &&
echo "${D}" &&
- echo "${ORANGE}[ WARNING ]${NORMAL} overlays present before setup" >&2 ||
+ echo "${YELLOW}[ WARNING ]${NORMAL} overlays present before setup" >&2 ||
echo "${GREEN}[ OK ]${NORMAL} no overlay present before setup" >&2
overlayfs_needed=true
D=`adb_sh cat /proc/mounts </dev/null |
@@ -1083,7 +1117,7 @@ rebooted=false
if [ X"${D}" != X"${H}" ]; then
echo "${H}"
if [ X"${D}" != X"${D##*setup failed}" ]; then
- echo "${ORANGE}[ WARNING ]${NORMAL} overlayfs setup whined" >&2
+ echo "${YELLOW}[ WARNING ]${NORMAL} overlayfs setup whined" >&2
fi
D=`adb_sh df -k </dev/null` &&
H=`echo "${D}" | head -1` &&
@@ -1130,7 +1164,7 @@ if [ X"${D}" != X"${D##*Successfully disabled verity}" ]; then
elif ${rebooted}; then
echo "${GREEN}[ OK ]${NORMAL} verity already disabled" >&2
else
- echo "${ORANGE}[ WARNING ]${NORMAL} verity already disabled" >&2
+ echo "${YELLOW}[ WARNING ]${NORMAL} verity already disabled" >&2
fi
echo "${GREEN}[ RUN ]${NORMAL} remount" >&2
@@ -1160,7 +1194,7 @@ if ${overlayfs_needed}; then
die -t ${T} "overlay takeover failed"
fi
echo "${D}" | grep "^overlay .* /system\$" >/dev/null ||
- echo "${ORANGE}[ WARNING ]${NORMAL} overlay takeover not complete" >&2
+ echo "${YELLOW}[ WARNING ]${NORMAL} overlay takeover not complete" >&2
if [ -z "${virtual_ab}" ]; then
scratch_partition=scratch
fi
@@ -1292,7 +1326,7 @@ echo "${GREEN}[ RUN ]${NORMAL} reboot to confirm content persistent" >&2
fixup_from_recovery() {
inRecovery || return 1
- echo "${ORANGE}[ ERROR ]${NORMAL} Device in recovery" >&2
+ echo "${YELLOW}[ ERROR ]${NORMAL} Device in recovery" >&2
adb reboot </dev/null
adb_wait ${ADB_WAIT}
}
@@ -1312,7 +1346,7 @@ if ${overlayfs_needed}; then
adb_su sed -n '1,/overlay \/system/p' /proc/mounts </dev/null |
skip_administrative_mounts |
grep -v ' \(erofs\|squashfs\|ext4\|f2fs\|vfat\) ' &&
- echo "${ORANGE}[ WARNING ]${NORMAL} overlay takeover after first stage init" >&2 ||
+ echo "${YELLOW}[ WARNING ]${NORMAL} overlay takeover after first stage init" >&2 ||
echo "${GREEN}[ OK ]${NORMAL} overlay takeover in first stage init" >&2
fi
@@ -1373,20 +1407,20 @@ is_bootloader_fastboot=false
is_userspace_fastboot=false
if ! ${is_bootloader_fastboot}; then
- echo "${ORANGE}[ WARNING ]${NORMAL} does not support fastboot, skipping"
+ echo "${YELLOW}[ WARNING ]${NORMAL} does not support fastboot, skipping"
elif [ -z "${ANDROID_PRODUCT_OUT}" ]; then
- echo "${ORANGE}[ WARNING ]${NORMAL} build tree not setup, skipping"
+ echo "${YELLOW}[ WARNING ]${NORMAL} build tree not setup, skipping"
elif [ ! -s "${ANDROID_PRODUCT_OUT}/vendor.img" ]; then
- echo "${ORANGE}[ WARNING ]${NORMAL} vendor image missing, skipping"
+ echo "${YELLOW}[ WARNING ]${NORMAL} vendor image missing, skipping"
elif [ "${ANDROID_PRODUCT_OUT}" = "${ANDROID_PRODUCT_OUT%*/${H}}" ]; then
- echo "${ORANGE}[ WARNING ]${NORMAL} wrong vendor image, skipping"
+ echo "${YELLOW}[ WARNING ]${NORMAL} wrong vendor image, skipping"
elif [ -z "${ANDROID_HOST_OUT}" ]; then
- echo "${ORANGE}[ WARNING ]${NORMAL} please run lunch, skipping"
+ echo "${YELLOW}[ WARNING ]${NORMAL} please run lunch, skipping"
elif ! (
adb_cat /vendor/build.prop |
cmp -s ${ANDROID_PRODUCT_OUT}/vendor/build.prop
) >/dev/null 2>/dev/null; then
- echo "${ORANGE}[ WARNING ]${NORMAL} vendor image signature mismatch, skipping"
+ echo "${YELLOW}[ WARNING ]${NORMAL} vendor image signature mismatch, skipping"
else
wait_for_screen
avc_check
@@ -1432,7 +1466,7 @@ else
fi
fastboot reboot ||
die "can not reboot out of fastboot"
- echo "${ORANGE}[ WARNING ]${NORMAL} adb after fastboot"
+ echo "${YELLOW}[ WARNING ]${NORMAL} adb after fastboot"
adb_wait ${ADB_WAIT} ||
fixup_from_recovery ||
die "did not reboot after formatting ${scratch_partition} `usb_status`"
@@ -1449,8 +1483,8 @@ else
if ${is_userspace_fastboot}; then
die "overlay supposed to be minus /vendor takeover after flash vendor"
else
- echo "${ORANGE}[ WARNING ]${NORMAL} user fastboot missing required to invalidate, ignoring a failure" >&2
- echo "${ORANGE}[ WARNING ]${NORMAL} overlay supposed to be minus /vendor takeover after flash vendor" >&2
+ echo "${YELLOW}[ WARNING ]${NORMAL} user fastboot missing required to invalidate, ignoring a failure" >&2
+ echo "${YELLOW}[ WARNING ]${NORMAL} overlay supposed to be minus /vendor takeover after flash vendor" >&2
fi
fi
B="`adb_cat /system/hello`"
@@ -1468,7 +1502,7 @@ else
check_eq "cat: /vendor/hello: No such file or directory" "${B}" \
vendor content after flash vendor
else
- echo "${ORANGE}[ WARNING ]${NORMAL} user fastboot missing required to invalidate, ignoring a failure" >&2
+ echo "${YELLOW}[ WARNING ]${NORMAL} user fastboot missing required to invalidate, ignoring a failure" >&2
check_eq "cat: /vendor/hello: No such file or directory" "${B}" \
--warning vendor content after flash vendor
fi
@@ -1489,7 +1523,7 @@ err=${?}
L=
D="${H%?Now reboot your device for settings to take effect*}"
if [ X"${H}" != X"${D}" ]; then
- echo "${ORANGE}[ WARNING ]${NORMAL} adb remount requires a reboot after partial flash (legacy avb)"
+ echo "${YELLOW}[ WARNING ]${NORMAL} adb remount requires a reboot after partial flash (legacy avb)"
L=`adb_logcat -b all -v nsec -t ${T} 2>&1`
adb_reboot &&
adb_wait ${ADB_WAIT} &&
@@ -1547,7 +1581,7 @@ if ${is_bootloader_fastboot} && [ -n "${scratch_partition}" ]; then
err=${?}
if [ X"${D}" != "${D%?Now reboot your device for settings to take effect*}" ]
then
- echo "${ORANGE}[ WARNING ]${NORMAL} adb disable-verity requires a reboot after partial flash"
+ echo "${YELLOW}[ WARNING ]${NORMAL} adb disable-verity requires a reboot after partial flash"
adb_reboot &&
adb_wait ${ADB_WAIT} &&
adb_root ||
@@ -1580,9 +1614,9 @@ fixup_from_fastboot() {
if [ -n "${ACTIVE_SLOT}" ]; then
local active_slot=`get_active_slot`
if [ X"${ACTIVE_SLOT}" != X"${active_slot}" ]; then
- echo "${ORANGE}[ ERROR ]${NORMAL} Active slot changed from ${ACTIVE_SLOT} to ${active_slot}"
+ echo "${YELLOW}[ ERROR ]${NORMAL} Active slot changed from ${ACTIVE_SLOT} to ${active_slot}"
else
- echo "${ORANGE}[ ERROR ]${NORMAL} Active slot to be set to ${ACTIVE_SLOT}"
+ echo "${YELLOW}[ ERROR ]${NORMAL} Active slot to be set to ${ACTIVE_SLOT}"
fi >&2
fastboot --set-active=${ACTIVE_SLOT}
fi