diff --git a/Android.bp b/Android.bp index bf7fac7e..45720c33 100644 --- a/Android.bp +++ b/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, +} + diff --git a/conf/fstab.efs.from_data b/conf/fstab.efs.from_data new file mode 100644 index 00000000..dbddeac5 --- /dev/null +++ b/conf/fstab.efs.from_data @@ -0,0 +1,8 @@ +# Android fstab file. +# +# 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 diff --git a/conf/init.efs.16k.rc b/conf/init.efs.16k.rc new file mode 100644 index 00000000..a9066835 --- /dev/null +++ b/conf/init.efs.16k.rc @@ -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 + diff --git a/conf/init.efs.4k.rc b/conf/init.efs.4k.rc new file mode 100644 index 00000000..506c7220 --- /dev/null +++ b/conf/init.efs.4k.rc @@ -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 diff --git a/conf/init.efs.rc b/conf/init.persist.rc similarity index 92% rename from conf/init.efs.rc rename to conf/init.persist.rc index d15dbc13..26a9c4d7 100644 --- a/conf/init.efs.rc +++ b/conf/init.persist.rc @@ -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 diff --git a/conf/init.zuma.rc b/conf/init.zuma.rc index c9dd76fe..b5c707e6 100644 --- a/conf/init.zuma.rc +++ b/conf/init.zuma.rc @@ -1,4 +1,5 @@ import /vendor/etc/init/hw/init.zuma.usb.rc +import /vendor/etc/init/hw/init.persist.rc import /vendor/etc/init/hw/init.efs.rc import android.hardware.drm@1.2-service.widevine.rc import init.exynos.sensorhub.rc diff --git a/copy_efs_files_to_data.sh b/copy_efs_files_to_data.sh new file mode 100644 index 00000000..bcbe8828 --- /dev/null +++ b/copy_efs_files_to_data.sh @@ -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" + diff --git a/device.mk b/device.mk index 7277acb8..ceb01f85 100644 --- a/device.mk +++ b/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/hw/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/hw/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/hw/init.efs.rc +endif ifneq (,$(filter userdebug eng, $(TARGET_BUILD_VARIANT))) PRODUCT_COPY_FILES += \ @@ -381,7 +392,8 @@ PRODUCT_PACKAGES += \ PRODUCT_COPY_FILES += \ device/google/$(TARGET_BOARD_PLATFORM)/conf/fstab.persist:$(TARGET_COPY_OUT_VENDOR)/etc/fstab.persist \ 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 + device/google/$(TARGET_BOARD_PLATFORM)/conf/fstab.efs:$(TARGET_COPY_OUT_VENDOR)/etc/fstab.efs \ + # Shell scripts PRODUCT_PACKAGES += \ @@ -1199,3 +1211,4 @@ include device/google/gs-common/touch/twoshay/twoshay.mk # since it can't be overridden from /vendor. PRODUCT_PRODUCT_PROPERTIES += \ dumpstate.strict_run=false +