Ver Fonte

fix(action): refine Android 12 and 13 SUSFS patch application logic

TheWildJames há 4 meses atrás
pai
commit
a776f038b5
1 ficheiros alterados com 35 adições e 33 exclusões
  1. 35 33
      .github/actions/susfs/action.yml

+ 35 - 33
.github/actions/susfs/action.yml

@@ -98,15 +98,12 @@ runs:
         FIX_REJ=0
         if [ "${{ inputs.kernel_version }}" = "5.10" ] && [ "${{ inputs.android_version }}" = "android12" ]; then
           echo "Applying Android 12 5.10 SUSFS fixes"
-          #if grep -q '^size_t this_len = min_t(size_t, count, PAGE_SIZE);$' fs/proc/base.c; then
-          #  sed -i 's/^int this_len = min_t(int, count, PAGE_SIZE);$/size_t this_len = min_t(size_t, count, PAGE_SIZE);/' fs/proc/base.c
-          #  FIX_REJ=1
-          #fi
-          #if ! grep -q '#include <linux/mnt_idmapping.h>$' fs/open.c; then
-          #  sed -i '/#include <linux\/compat.h>$/a #include <linux/mnt_idmapping.h>' fs/open.c
-          #  FIX_REJ=1
-          #fi
-        elif [ "${{ inputs.kernel_version }}" = "5.15" ] && [ "${{ inputs.android_version }}" = "android13" ]; then
+          if [ "${{ inputs.sublevel }}" -le "43" ]; then
+            sed -i 's/^int this_len = min_t(int, count, PAGE_SIZE);$/size_t this_len = min_t(size_t, count, PAGE_SIZE);/' fs/proc/base.c
+          fi
+        fi
+        if [ "${{ inputs.kernel_version }}" = "5.15" ] && [ "${{ inputs.android_version }}" = "android13" ]; then
+          echo "Applying Android 13 5.15 SUSFS fixes"
           if grep -q '^size_t this_len = min_t(size_t, count, PAGE_SIZE);$' fs/proc/base.c; then
             sed -i 's/^int this_len = min_t(int, count, PAGE_SIZE);$/size_t this_len = min_t(size_t, count, PAGE_SIZE);/' fs/proc/base.c
             FIX_REJ=1
@@ -119,12 +116,15 @@ runs:
             sed -i '/^#include <linux\/compat.h>$/a #include <linux/mnt_idmapping.h>' fs/open.c
             FIX_REJ=1
           fi
-        elif [ "${{ inputs.kernel_version }}" = "6.1" ]; then
+        fi
+        if [ "${{ inputs.kernel_version }}" = "6.1" ]; then
           if grep -q '^#include <trace/hooks/blk.h>$' fs/namespace.c; then
             sed -i '/^#include <trace\/hooks\/blk.h>$/d' fs/namespace.c
             FIX_REJ=1
           fi
-        elif [ "${{ inputs.kernel_version }}" = "6.6" ]; then
+        fi
+        if [ "${{ inputs.kernel_version }}" = "6.6" ]; then
+          echo "Applying 6.6 SUSFS fixes"
           if ! grep -q '^#include <trace/hooks/fs.h>$' fs/namespace.c; then
             sed -i '/^#include <trace\/hooks\/blk.h>$/a #include <trace/hooks/fs.h>' fs/namespace.c
             FIX_REJ=1
@@ -142,7 +142,9 @@ runs:
             }' fs/proc/task_mmu.c
             FIX_REJ=1
           fi
-        elif [ "${{ inputs.kernel_version }}" = "6.12" ]; then
+        fi
+        if [ "${{ inputs.kernel_version }}" = "6.12" ]; then
+          echo "Applying 6.12 SUSFS fixes"
           if grep -q '^#include <linux/dma-buf.h>$' fs/exec.c; then
             sed -i '/^#include <linux\/dma-buf.h>$/d' fs/exec.c
             FIX_REJ=1
@@ -153,28 +155,28 @@ runs:
 
         patch -p1 < 50_add_susfs_in_gki-${{ inputs.android_version }}-${{ inputs.kernel_version }}.patch || true
 
-        if [ "$FIX_REJ" = "1" ]; then
-          if [ "${{ inputs.kernel_version }}" = "5.10" ] && [ "${{ inputs.android_version }}" = "android12" ]; then
-            sed -i 's/^size_t this_len = min_t(size_t, count, PAGE_SIZE);$/int this_len = min_t(int, count, PAGE_SIZE);/' fs/proc/base.c
-          elif [ "${{ inputs.kernel_version }}" = "5.15" ] && [ "${{ inputs.android_version }}" = "android13" ]; then
-            sed -i '/#include <linux\/mnt_idmapping.h>$/d' fs/namespace.c
-            sed -i '/#include <linux\/mnt_idmapping.h>$/d' fs/open.c
-            sed -i 's/^size_t this_len = min_t(size_t, count, PAGE_SIZE);$/int this_len = min_t(int, count, PAGE_SIZE);/' fs/proc/base.c
-          elif [ "${{ inputs.kernel_version }}" = "6.1" ]; then
-            sed -i '/^#include "internal.h"$/a #include <trace/hooks/blk.h>' fs/namespace.c
-          elif [ "${{ inputs.kernel_version }}" = "6.6" ]; then
-            sed -i '/^#include <trace\/hooks\/fs.h>$/d' fs/namespace.c
-            sed -i '/^#include <linux\/dma-buf.h>$/d' fs/proc/base.c
-            sed -i '/unsigned int nr_subpages.*__PAGE_SIZE.*PAGE_SIZE/d' fs/proc/task_mmu.c
-            sed -i '/pagemap_entry_t.*res.*NULL/d' fs/proc/task_mmu.c
-          elif [ "${{ inputs.kernel_version }}" = "6.12" ]; then
-            if ! grep -q '^#include <linux/dma-buf.h>$' fs/exec.c; then
-            sed -i '/^#include <linux\/ksh.h>$/a #include <linux/dma-buf.h>' fs/exec.c
-            FIX_REJ=1
-          fi
-          fi
+        if [ "${{ inputs.kernel_version }}" = "5.10" ] && [ "${{ inputs.android_version }}" = "android12" ] && [ "${{ inputs.sublevel }}" = "43" ]; then
+          sed -i 's/^size_t this_len = min_t(size_t, count, PAGE_SIZE);$/int this_len = min_t(int, count, PAGE_SIZE);/' fs/proc/base.c
         fi
-
+        if [ "${{ inputs.kernel_version }}" = "5.15" ] && [ "${{ inputs.android_version }}" = "android13" ]; then
+          sed -i '/#include <linux\/mnt_idmapping.h>$/d' fs/namespace.c
+          sed -i '/#include <linux\/mnt_idmapping.h>$/d' fs/open.c
+          sed -i 's/^size_t this_len = min_t(size_t, count, PAGE_SIZE);$/int this_len = min_t(int, count, PAGE_SIZE);/' fs/proc/base.c
+        fi
+        if [ "${{ inputs.kernel_version }}" = "6.1" ]; then
+          sed -i '/^#include "internal.h"$/a #include <trace/hooks/blk.h>' fs/namespace.c
+        fi
+        if [ "${{ inputs.kernel_version }}" = "6.6" ]; then
+          sed -i '/^#include <trace\/hooks\/fs.h>$/d' fs/namespace.c
+          sed -i '/^#include <linux\/dma-buf.h>$/d' fs/proc/base.c
+          sed -i '/unsigned int nr_subpages.*__PAGE_SIZE.*PAGE_SIZE/d' fs/proc/task_mmu.c
+          sed -i '/pagemap_entry_t.*res.*NULL/d' fs/proc/task_mmu.c
+        fi
+        if [ "${{ inputs.kernel_version }}" = "6.12" ]; then
+          sed -i '/^#include <linux\/ksh.h>$/a #include <linux/dma-buf.h>' fs/exec.c
+          FIX_REJ=1
+        fi
+        
         SHOW_PAD_FIX=0
         if [[ "${{ inputs.android_version }}" = "android12" && "${{ inputs.kernel_version }}" = "5.10" && "${{ inputs.sublevel }}" -le 209 ]]; then
           SHOW_PAD_FIX=1