From 23425fbc5493b1e186007c3b07cbfb17cc6a4927 Mon Sep 17 00:00:00 2001 From: Vilas Bhat Date: Fri, 3 Jan 2025 18:08:52 +0000 Subject: [PATCH] 16KB: Move copy_efs_file_to_data script to gs-common There are 4 partitions that are flashed at the factory and use F2FS fs with 4KB block size: - /dev/block/by-name/efs - /dev/block/by-name/efs_backup - /dev/block/by-name/modem_userdata - /dev/block/by-name/persist These partitions can NOT be mounted by 16KB kernels because F2FS expects BLOCK_SIZE == PAGE_SIZE. In order for the files in these partitions to be accessible to 16KB kernels, the dump.f2fs tool is used. This change will perform these steps at boot time ONLY for 16KB mode. For every partition (efs/efs_backup/modem_userdata/persist): 1. Use dump.f2fs to copy the content of the partition to /data/vendor/copied/.img. 2. If the copy was succesfull, rename /data/vendor/copied/.img to /data/vendor/copied/ 3. fsync the content of the directory /data/vendor/copied/. After the content of the partitions is in /data/vendor/copied, bind-mount the partitions to the directory /mnt/vendor. See conf/fstab.efs.from_data. Note: This change ONLY applies to 16KB kernels. This change does not modify the original partitions. Test: Boot test and Enable16kbTest for Pixel 8 & Pixel 9 targets Fingerprint and Phone Calls work in 16KB mode Bug: 383151792 Flag: EXEMPT bugfix Change-Id: Ib67fd8678f8bd97bd50663657046c28137bd4435 --- 16kb/16kb.mk | 22 +++++++++++++++++++ 16kb/Android.bp | 13 ++++++++++++ 16kb/copy_efs_files_to_data.sh | 39 ++++++++++++++++++++++++++++++++++ 3 files changed, 74 insertions(+) create mode 100644 16kb/16kb.mk create mode 100644 16kb/Android.bp create mode 100644 16kb/copy_efs_files_to_data.sh diff --git a/16kb/16kb.mk b/16kb/16kb.mk new file mode 100644 index 0000000..96bfd89 --- /dev/null +++ b/16kb/16kb.mk @@ -0,0 +1,22 @@ +# +# Copyright (C) 2025 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. +# + +####################################################################### +# WARNING: Any rule defined here automatically gets inherited for +# *BOTH* 4 KB and 16 KB targets where this file is included. +####################################################################### + +PRODUCT_PACKAGES += copy_efs_files_to_data diff --git a/16kb/Android.bp b/16kb/Android.bp new file mode 100644 index 0000000..e9bd6ac --- /dev/null +++ b/16kb/Android.bp @@ -0,0 +1,13 @@ +package { + default_applicable_licenses: ["Android-Apache-2.0"], +} + +// 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/16kb/copy_efs_files_to_data.sh b/16kb/copy_efs_files_to_data.sh new file mode 100644 index 0000000..e1d2204 --- /dev/null +++ b/16kb/copy_efs_files_to_data.sh @@ -0,0 +1,39 @@ +#!/vendor/bin/sh + +CHECKPOINT_DIR=/data/vendor/copied + +export BIN_DIR=/vendor/bin + +$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/mkdir -p $tmpdir + $BIN_DIR/dump.f2fs -rfPLo $tmpdir $block_device + if [ $? -ne 0 ]; then + echo "Failed to $BIN_DIR/dump.f2fs -rfPLo $tmpdir $block_device" + return + fi + $BIN_DIR/mv $tmpdir $build_checkpoint + if [ $? -ne 0 ]; then + echo "mv $tmpdir $build_checkpoint" + return + fi + $BIN_DIR/fsync `dirname $build_checkpoint` + fi + echo "Successfully copied $mount_point to $build_checkpoint" +} + +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" +copy_files_to_data "/dev/block/by-name/persist" "/mnt/vendor/persist" + +$BIN_DIR/fsync /data/vendor/copied