Reland: Copy files on EFS partition to /data on boot
During boot, this CL adds the following sequence of actions: 1. mount original efs partitions(most likely f2fs) on /mnt/vendor/efs 2. copy files in /mnt/vendor/efs to /data/vendor/copied/efs.img 3. fsync all the files in /data/vendor/copied/efs.img 4. rename /data/vendor/copied/efs.img to /data/vendor/copied/efs 5. bind-mount /data/vendor/copied/efs to /mnt/vendor/efs 6. repeat 1-5 for efs_backup and modem_userdata The original EFS partitions are mounted and only used for file copying, no destructive action done on original efs partitions. Test: reformat /data as ext4, boot the device Bug: 319335586 Change-Id: Ide78be316778acfc5c582c4a7b78853796cf4c1e
This commit is contained in:
parent
4053a85fe7
commit
b08f8dbf23
8 changed files with 103 additions and 7 deletions
11
Android.bp
11
Android.bp
|
@ -41,3 +41,14 @@ sh_binary {
|
|||
vendor: true,
|
||||
sub_dir: "hw",
|
||||
}
|
||||
|
||||
// Filesystem: Copy efs/efs_backup/modem_userdata to /data partition
|
||||
// so that they can be accessed under 16K mode. By default, these partitions
|
||||
// are 4K F2FS , which can't be mounted under 16K mode.
|
||||
// (b/293313353)
|
||||
sh_binary {
|
||||
name: "copy_efs_files_to_data",
|
||||
src: "copy_efs_files_to_data.sh",
|
||||
vendor: true,
|
||||
}
|
||||
|
||||
|
|
8
conf/fstab.efs.from_data
Normal file
8
conf/fstab.efs.from_data
Normal file
|
@ -0,0 +1,8 @@
|
|||
# Android fstab file.
|
||||
# <src> <mnt_point> <type> <mnt_flags and options> <fs_mgr_flags>
|
||||
# Create the specific fstab file for efs partitions for flexibility
|
||||
/data/vendor/copied/efs /mnt/vendor/efs none bind latemount
|
||||
|
||||
/data/vendor/copied/efs_backup /mnt/vendor/efs_backup none bind latemount
|
||||
|
||||
/data/vendor/copied/modem_userdata /mnt/vendor/modem_userdata none bind latemount
|
27
conf/init.efs.16k.rc
Normal file
27
conf/init.efs.16k.rc
Normal file
|
@ -0,0 +1,27 @@
|
|||
|
||||
service copy_efs_files_to_data /vendor/bin/copy_efs_files_to_data
|
||||
user root
|
||||
group root radio system audio media graphics camera
|
||||
stdio_to_kmsg
|
||||
oneshot
|
||||
disabled
|
||||
|
||||
on post-fs-data && property:ro.boot.flash.locked=0
|
||||
mkdir /data/vendor/copied 0775 radio system
|
||||
restorecon_recursive /data/vendor/copied
|
||||
restorecon_recursive /mnt/vendor
|
||||
mount_all /vendor/etc/fstab.efs
|
||||
exec_start copy_efs_files_to_data
|
||||
umount_all /vendor/etc/fstab.efs
|
||||
mount_all /vendor/etc/fstab.efs.from_data
|
||||
mount_all /vendor/etc/fstab.persist
|
||||
restorecon_recursive /mnt/vendor/efs
|
||||
restorecon_recursive /mnt/vendor/efs_backup
|
||||
restorecon_recursive /mnt/vendor/modem_userdata
|
||||
setprop ro.vendor.persist.status mounted
|
||||
|
||||
on post-fs-data && property:ro.boot.flash.locked=1
|
||||
mount_all /vendor/etc/fstab.efs
|
||||
mount_all /vendor/etc/fstab.persist
|
||||
setprop ro.vendor.persist.status mounted
|
||||
|
4
conf/init.efs.4k.rc
Normal file
4
conf/init.efs.4k.rc
Normal file
|
@ -0,0 +1,4 @@
|
|||
on post-fs-data
|
||||
mount_all /vendor/etc/fstab.efs
|
||||
mount_all /vendor/etc/fstab.persist
|
||||
setprop ro.vendor.persist.status mounted
|
|
@ -36,8 +36,3 @@ on property:ro.vendor.persist.status=mounted
|
|||
chown system system /data/vendor/ss/persist/nsp
|
||||
|
||||
restart storageproxyd
|
||||
|
||||
on post-fs-data
|
||||
mount_all /vendor/etc/fstab.efs
|
||||
mount_all /vendor/etc/fstab.persist
|
||||
setprop ro.vendor.persist.status mounted
|
|
@ -1,5 +1,4 @@
|
|||
import /vendor/etc/init/hw/init.zuma.usb.rc
|
||||
import /vendor/etc/init/hw/init.efs.rc
|
||||
import android.hardware.drm@1.2-service.widevine.rc
|
||||
import init.exynos.sensorhub.rc
|
||||
|
||||
|
|
40
copy_efs_files_to_data.sh
Normal file
40
copy_efs_files_to_data.sh
Normal file
|
@ -0,0 +1,40 @@
|
|||
#!/vendor/bin/sh
|
||||
|
||||
CHECKPOINT_DIR=/data/vendor/copied
|
||||
|
||||
BIN_DIR=/vendor/bin
|
||||
|
||||
$BIN_DIR/mkdir -p $CHECKPOINT_DIR
|
||||
|
||||
function copy_files_to_data()
|
||||
{
|
||||
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
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Failed to cp -rp $mount_point $tmpdir"
|
||||
return
|
||||
fi
|
||||
fsync `find $tmpdir -type fd`
|
||||
mv $tmpdir $build_checkpoint
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "mv $tmpdir $build_checkpoint"
|
||||
return
|
||||
fi
|
||||
fsync `dirname $build_checkpoint`
|
||||
fi
|
||||
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"
|
||||
|
14
device.mk
14
device.mk
|
@ -358,7 +358,18 @@ PRODUCT_COPY_FILES += \
|
|||
|
||||
PRODUCT_COPY_FILES += \
|
||||
device/google/zuma/conf/init.zuma.rc:$(TARGET_COPY_OUT_VENDOR)/etc/init/hw/init.zuma.rc \
|
||||
device/google/zuma/conf/init.efs.rc:$(TARGET_COPY_OUT_VENDOR)/etc/init/hw/init.efs.rc
|
||||
device/google/zuma/conf/init.persist.rc:$(TARGET_COPY_OUT_VENDOR)/etc/init/init.persist.rc
|
||||
|
||||
ifeq (true,$(PRODUCT_16K_DEVELOPER_OPTION))
|
||||
PRODUCT_COPY_FILES += \
|
||||
device/google/zuma/conf/init.efs.16k.rc:$(TARGET_COPY_OUT_VENDOR)/etc/init/init.efs.rc \
|
||||
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
|
||||
else
|
||||
PRODUCT_COPY_FILES += \
|
||||
device/google/zuma/conf/init.efs.4k.rc:$(TARGET_COPY_OUT_VENDOR)/etc/init/init.efs.rc
|
||||
endif
|
||||
|
||||
ifneq (,$(filter userdebug eng, $(TARGET_BUILD_VARIANT)))
|
||||
PRODUCT_COPY_FILES += \
|
||||
|
@ -383,6 +394,7 @@ PRODUCT_COPY_FILES += \
|
|||
device/google/$(TARGET_BOARD_PLATFORM)/conf/fstab.modem:$(TARGET_COPY_OUT_VENDOR)/etc/fstab.modem \
|
||||
device/google/$(TARGET_BOARD_PLATFORM)/conf/fstab.efs:$(TARGET_COPY_OUT_VENDOR)/etc/fstab.efs
|
||||
|
||||
|
||||
# Shell scripts
|
||||
PRODUCT_PACKAGES += \
|
||||
disable_contaminant_detection.sh
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue