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
This commit is contained in:
Kelvin Zhang 2024-06-04 09:56:33 -07:00
parent 5978809ae7
commit e3ed1eabdf
3 changed files with 5 additions and 13 deletions

View file

@ -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 on post-fs-data && property:ro.boot.flash.locked=0 && property:ro.fstype.data=ext4
mkdir /data/vendor/copied 0775 radio system mkdir /data/vendor/copied 0775 radio system
restorecon_recursive /data/vendor/copied 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 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 mount_all /vendor/etc/fstab.efs.from_data
restorecon_recursive /mnt/vendor/efs restorecon_recursive /mnt/vendor/efs
restorecon_recursive /mnt/vendor/efs_backup restorecon_recursive /mnt/vendor/efs_backup

View file

@ -8,19 +8,19 @@ $BIN_DIR/mkdir -p $CHECKPOINT_DIR
function copy_files_to_data() function copy_files_to_data()
{ {
block_device=$1
partition_name=$(basename $1) partition_name=$(basename $1)
mount_point=$2 mount_point=$2
tmpdir=$CHECKPOINT_DIR/$partition_name.img tmpdir=$CHECKPOINT_DIR/$partition_name.img
build_checkpoint=$CHECKPOINT_DIR/$partition_name build_checkpoint=$CHECKPOINT_DIR/$partition_name
if [ ! -e $build_checkpoint ]; then if [ ! -e $build_checkpoint ]; then
$BIN_DIR/rm -rf $tmpdir $BIN_DIR/rm -rf $tmpdir
$BIN_DIR/rm -rf $build_checkpoint $BIN_DIR/mkdir -p $tmpdir
cp -rp $mount_point $tmpdir $BIN_DIR/dump.f2fs -rfPo $tmpdir $block_device
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "Failed to cp -rp $mount_point $tmpdir" echo "Failed to $BIN_DIR/dump.f2fs -rfPo $tmpdir $block_device"
return return
fi fi
fsync `find $tmpdir -type fd`
mv $tmpdir $build_checkpoint mv $tmpdir $build_checkpoint
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "mv $tmpdir $build_checkpoint" echo "mv $tmpdir $build_checkpoint"
@ -31,12 +31,8 @@ function copy_files_to_data()
echo "Successfully copied $mount_point to $build_checkpoint" 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" "/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/efs_backup" "/mnt/vendor/efs_backup"
copy_files_to_data "/dev/block/by-name/modem_userdata" "/mnt/vendor/modem_userdata" 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" copy_files_to_data "/dev/block/by-name/persist" "/mnt/vendor/persist"

View file

@ -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 \ 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 += copy_efs_files_to_data
PRODUCT_PACKAGES += fsck.f2fs.vendor
else else
PRODUCT_COPY_FILES += \ PRODUCT_COPY_FILES += \
device/google/zuma/conf/init.efs.4k.rc:$(TARGET_COPY_OUT_VENDOR)/etc/init/init.efs.rc device/google/zuma/conf/init.efs.4k.rc:$(TARGET_COPY_OUT_VENDOR)/etc/init/init.efs.rc