From e3ed1eabdf56bb1d7ef9b01b45014639ca890f10 Mon Sep 17 00:00:00 2001 From: Kelvin Zhang Date: Tue, 4 Jun 2024 09:56:33 -0700 Subject: [PATCH] Use dump.f2fs to extract files from efs partitions Previously, we rely on mount points to copy files out of efs partitions. Switch over to dump.f2fs to read directly from block device without mounting. This allows us to copy files out of efs partition in both 4K and 16K mode. Test: Boot dev option enabled ext4 device Bug: 340965747 Change-Id: I9d3f3d5200adc31f13298488b5be068b0fe7c7f4 --- conf/init.efs.16k.rc | 5 ----- copy_efs_files_to_data.sh | 12 ++++-------- device.mk | 1 + 3 files changed, 5 insertions(+), 13 deletions(-) diff --git a/conf/init.efs.16k.rc b/conf/init.efs.16k.rc index 9e891680..c3434bfd 100644 --- a/conf/init.efs.16k.rc +++ b/conf/init.efs.16k.rc @@ -9,12 +9,7 @@ service copy_efs_files_to_data /vendor/bin/copy_efs_files_to_data on post-fs-data && property:ro.boot.flash.locked=0 && property:ro.fstype.data=ext4 mkdir /data/vendor/copied 0775 radio system restorecon_recursive /data/vendor/copied - restorecon_recursive /mnt/vendor - mount_all /vendor/etc/fstab.efs - mount_all /vendor/etc/fstab.persist exec_start copy_efs_files_to_data - umount_all /vendor/etc/fstab.efs - umount_all /vendor/etc/fstab.persist mount_all /vendor/etc/fstab.efs.from_data restorecon_recursive /mnt/vendor/efs restorecon_recursive /mnt/vendor/efs_backup diff --git a/copy_efs_files_to_data.sh b/copy_efs_files_to_data.sh index 898bc8e9..2ac9e462 100644 --- a/copy_efs_files_to_data.sh +++ b/copy_efs_files_to_data.sh @@ -8,19 +8,19 @@ $BIN_DIR/mkdir -p $CHECKPOINT_DIR function copy_files_to_data() { + block_device=$1 partition_name=$(basename $1) mount_point=$2 tmpdir=$CHECKPOINT_DIR/$partition_name.img build_checkpoint=$CHECKPOINT_DIR/$partition_name if [ ! -e $build_checkpoint ]; then $BIN_DIR/rm -rf $tmpdir - $BIN_DIR/rm -rf $build_checkpoint - cp -rp $mount_point $tmpdir + $BIN_DIR/mkdir -p $tmpdir + $BIN_DIR/dump.f2fs -rfPo $tmpdir $block_device if [ $? -ne 0 ]; then - echo "Failed to cp -rp $mount_point $tmpdir" + echo "Failed to $BIN_DIR/dump.f2fs -rfPo $tmpdir $block_device" return fi - fsync `find $tmpdir -type fd` mv $tmpdir $build_checkpoint if [ $? -ne 0 ]; then echo "mv $tmpdir $build_checkpoint" @@ -31,12 +31,8 @@ function copy_files_to_data() echo "Successfully copied $mount_point to $build_checkpoint" } -chmod g+rx -R /mnt/vendor/efs -chmod g+rx -R /mnt/vendor/efs_backup -chmod g+rx -R /mnt/vendor/modem_userdata copy_files_to_data "/dev/block/by-name/efs" "/mnt/vendor/efs" copy_files_to_data "/dev/block/by-name/efs_backup" "/mnt/vendor/efs_backup" copy_files_to_data "/dev/block/by-name/modem_userdata" "/mnt/vendor/modem_userdata" -chmod g+rx -R /mnt/vendor/persist copy_files_to_data "/dev/block/by-name/persist" "/mnt/vendor/persist" diff --git a/device.mk b/device.mk index bcf96249..8d705f32 100644 --- a/device.mk +++ b/device.mk @@ -366,6 +366,7 @@ PRODUCT_COPY_FILES += \ device/google/$(TARGET_BOARD_PLATFORM)/conf/fstab.efs.from_data:$(TARGET_COPY_OUT_VENDOR)/etc/fstab.efs.from_data \ PRODUCT_PACKAGES += copy_efs_files_to_data +PRODUCT_PACKAGES += fsck.f2fs.vendor else PRODUCT_COPY_FILES += \ device/google/zuma/conf/init.efs.4k.rc:$(TARGET_COPY_OUT_VENDOR)/etc/init/init.efs.rc