From 25d7b4c53982f48ebd78b5bd7d0d6856f49cdf10 Mon Sep 17 00:00:00 2001 From: Pierre-Hugues Husson Date: Tue, 3 Apr 2018 00:13:48 +0200 Subject: [PATCH] Resize /system in boot Is it really safe? Tested on Allview V3 Viper and Huawei Mate 9 --- base.mk | 3 +++ resize-system.sh | 11 +++++++++++ sepolicy/file_contexts | 1 + sepolicy/resize.te | 6 ++++++ vndk.rc | 1 + 5 files changed, 22 insertions(+) create mode 100644 resize-system.sh create mode 100644 sepolicy/resize.te diff --git a/base.mk b/base.mk index c1415aa..584cacc 100644 --- a/base.mk +++ b/base.mk @@ -43,5 +43,8 @@ PRODUCT_COPY_FILES += \ PRODUCT_COPY_FILES += \ device/phh/treble/nfc/libnfc-nci.conf:system/etc/libnfc-nci.conf +PRODUCT_COPY_FILES += \ + device/phh/treble/resize-system.sh:system/bin/resize-system.sh + PRODUCT_PACKAGES += \ treble-environ-rc diff --git a/resize-system.sh b/resize-system.sh new file mode 100644 index 0000000..cc90237 --- /dev/null +++ b/resize-system.sh @@ -0,0 +1,11 @@ +#!/system/bin/sh + +set -e + +if [ "grep ' /system ' /proc/mounts |cut -d ' ' -f 1 |wc -l" -ne 1 ];then + exit 0 +fi + +mount -o remount,rw /system +resize2fs $(grep ' /system ' /proc/mounts |cut -d ' ' -f 1) +mount -o remount,ro /system diff --git a/sepolicy/file_contexts b/sepolicy/file_contexts index f80dc3a..e4a62b8 100644 --- a/sepolicy/file_contexts +++ b/sepolicy/file_contexts @@ -1,3 +1,4 @@ /system/bin/phh-su u:object_r:phhsu_exec:s0 /system/bin/vndk-detect u:object_r:vndk_detect_exec:s0 /system/etc/usb_audio_policy_configuration.xml u:object_r:vendor_configs_file:s0 +/system/bin/resize-system.sh u:object_r:update_engine_exec:s0 diff --git a/sepolicy/resize.te b/sepolicy/resize.te new file mode 100644 index 0000000..12d95c6 --- /dev/null +++ b/sepolicy/resize.te @@ -0,0 +1,6 @@ +allow update_engine { toolbox_exec system_file }:file rx_file_perms; +allow update_engine labeledfs:filesystem remount; + +allow update_engine sysfs_fs_ext4_features:dir r_dir_perms; +allow update_engine sysfs_fs_ext4_features:file r_file_perms; +allow update_engine self:capability { sys_resource }; diff --git a/vndk.rc b/vndk.rc index 064f0ae..7a31398 100644 --- a/vndk.rc +++ b/vndk.rc @@ -1,4 +1,5 @@ on post-fs exec - root -- /system/bin/vndk-detect + exec - root -- /system/bin/resize-system.sh mount none /system/etc/usb_audio_policy_configuration.xml /vendor/etc/usb_audio_policy_configuration.xml bind export LD_CONFIG_FILE /system/etc/ld.config.${persist.sys.vndk}.txt