Browse Source

Implement zeromount fixes in build workflow

Added fixes for zeromount in task_mmu.c, stat.c, and Kconfig.
jimsterino98 5 tháng trước cách đây
mục cha
commit
70a001e5ce
1 tập tin đã thay đổi với 25 bổ sung0 xóa
  1. 25 0
      .github/workflows/build.yml

+ 25 - 0
.github/workflows/build.yml

@@ -271,6 +271,31 @@ jobs:
           #patch -p1 < 51_enhanced_susfs_gki-${{ inputs.android_version }}-${{ inputs.kernel_version }}.patch || true
           patch -p1 < 60_zeromount-${{ inputs.android_version }}-${{ inputs.kernel_version }}.patch || true
           rm -rf 60_zeromount-${{ inputs.android_version }}-${{ inputs.kernel_version }}.patch
+
+          if [ -f fs/proc/task_mmu.c ]; then
+            echo "Fixing task_mmu.c..."
+
+            sed -i '/pgoff = ((loff_t)vma->vm_pgoff) << PAGE_SHIFT;/a\
+            #ifdef CONFIG_ZEROMOUNT\
+            \tzeromount_spoof_mmap_metadata(inode, \&dev, \&ino);\
+            #endif' fs/proc/task_mmu.c
+          fi
+
+          if [ -f fs/stat.c.rej ]; then
+          echo "Applying zeromount vfs_statx fix..."
+
+            if ! grep -q 'zeromount_stat_hook(dfd, filename, stat, request_mask, flags)' fs/stat.c; then
+              perl -0pi -e 's@(static int vfs_statx\(.*?\)\s*\{.*?orig_flow:\n#endif\n)@$1\n#ifdef CONFIG_ZEROMOUNT\n\tif (filename) {\n\t\tint zm_ret = zeromount_stat_hook(dfd, filename, stat, request_mask, flags);\n\t\tif (zm_ret != -ENOENT)\n\t\t\treturn zm_ret;\n\t}\n#endif\n\n@s' fs/stat.c
+            fi
+          fi
+
+          if [ -f fs/Kconfig.rej ]; then
+              echo "Applying Kconfig zeromount fix..."
+
+              if ! grep -q 'config ZEROMOUNT' fs/Kconfig; then
+                perl -0pi -e 's@(config IO_WQ.*?\n(?:\t.*\n)*?)@\1\nconfig ZEROMOUNT\n\tbool "Enable zeromount"\n\tdefault n\n\n@s' fs/Kconfig
+              fi
+          fi
           #patch -p1 < 70_ksu_safety-wksu-${{ inputs.kernel_version }}.patch || true
 
           cd "$GITHUB_WORKSPACE"