Просмотр исходного кода

feat(fdinfo): add inotify_fdinfo implementation for SUSFS support

TheWildJames 4 месяцев назад
Родитель
Сommit
c9f44cdad4
1 измененных файлов с 32 добавлено и 19 удалено
  1. 32 19
      .github/actions/susfs/action.yml

+ 32 - 19
.github/actions/susfs/action.yml

@@ -84,7 +84,7 @@ runs:
         cp "${{ github.workspace }}/susfs4ksu/kernel_patches/include/linux/"* "${{ github.workspace }}/kernel/common/include/linux/"
         cp ${{ github.workspace }}/susfs4ksu/kernel_patches/50_add_susfs_in_gki-${{ inputs.android_version }}-${{ inputs.kernel_version }}.patch ./
 
-        FIX_REJ=0
+
         if [ "${{ inputs.kernel_version }}" = "5.10" ] && [ "${{ inputs.android_version }}" = "android12" ]; then
           echo "Applying Android 12 5.10 SUSFS fixes"
           if [ "${{ inputs.sublevel }}" -le "43" ]; then
@@ -92,39 +92,40 @@ runs:
           fi
           if [ "${{ inputs.sublevel }}" -le "117" ]; then
             sed -i '/^\s*\/\*/,/^\s*u32 mask = mark->mask & IN_ALL_EVENTS;$/d' fs/notify/fdinfo.c
-            perl -i -pe 's/\bmask,\s*mark->ignored_mask\)/inotify_mark_user_mask(mark)/g' fs/notify/fdinfo.c
+            perl -i -pe 's/\bmask,\s*mark->ignored_mask/inotify_mark_user_mask(mark)/g' fs/notify/fdinfo.c
           fi
         fi
+
+
         if [ "${{ inputs.kernel_version }}" = "5.10" ] && [ "${{ inputs.android_version }}" = "android13" ]; then
           echo "Applying Android 13 5.10 SUSFS fixes"
           if [ "${{ inputs.sublevel }}" -le "107" ]; then
-            perl -i -pe 's/^\s*u32 mask = mark->mask & IN_ALL_EVENTS;?\s*$//g' fs/notify/fdinfo.c
-            perl -i -pe 's/\bmask,\s*mark->ignored_mask\)/inotify_mark_user_mask(mark)/g' fs/notify/fdinfo.c
+            sed -i '/^\s*\/\*/,/^\s*u32 mask = mark->mask & IN_ALL_EVENTS;$/d' fs/notify/fdinfo.c
+            perl -i -pe 's/\bmask,\s*mark->ignored_mask/inotify_mark_user_mask(mark)/g' fs/notify/fdinfo.c
           fi
         fi
+
+
         if [ "${{ inputs.kernel_version }}" = "5.15" ] && [ "${{ inputs.android_version }}" = "android13" ]; then
           echo "Applying Android 13 5.15 SUSFS fixes"
           if [ "${{ inputs.sublevel }}" -le "43" ]; then
-            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/namespace.c; then
-              sed -i '/^#include <linux\/shmem_fs.h>$/a #include <linux/mnt_idmapping.h>' fs/namespace.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
+            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
+            sed -i '/^#include <linux\/shmem_fs.h>$/a #include <linux/mnt_idmapping.h>' fs/namespace.c
+            sed -i '/^#include <linux\/compat.h>$/a #include <linux/mnt_idmapping.h>' fs/open.c
+            sed -i '/^\s*\/\*/,/^\s*u32 mask = mark->mask & IN_ALL_EVENTS;$/d' fs/notify/fdinfo.c
+            perl -i -pe 's/\bmask,\s*mark->ignored_mask/inotify_mark_user_mask(mark)/g' fs/notify/fdinfo.c
           fi
         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
         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
@@ -145,6 +146,8 @@ runs:
             FIX_REJ=1
           fi
         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
@@ -161,31 +164,41 @@ runs:
           fi
           if [ "${{ inputs.sublevel }}" -le "117" ]; then
             perl -i -pe 's/^(\s*if \(inode\) \{)/$1\n        \/\*\n         * IN_ALL_EVENTS represents all of the mask bits\n         * that we expose to userspace.  There is at\n         * least one bit (FS_EVENT_ON_CHILD) which is\n         * used only internally to the kernel.\n         *\/\n        u32 mask = mark->mask & IN_ALL_EVENTS;/m' fs/notify/fdinfo.c
-            perl -i -pe 's/\binotify_mark_user_mask\(mark\)/mask, mark->ignored_mask)/g' fs/notify/fdinfo.c
+            perl -i -pe 's/\binotify_mark_user_mask\(mark\)/mask, mark->ignored_mask/g' fs/notify/fdinfo.c
           fi
         fi
+
+
         if [ "${{ inputs.kernel_version }}" = "5.10" ] && [ "${{ inputs.android_version }}" = "android13" ]; then
           if [ "${{ inputs.sublevel }}" -le "107" ]; then
-            perl -i -pe 's/^(\s*if $$inode$$ \{)/$1\n        u32 mask = mark->mask & IN_ALL_EVENTS;/' fs/notify/fdinfo.c
-            perl -i -pe 's/\binotify_mark_user_mask\(mark\)/mask, mark->ignored_mask)/g' fs/notify/fdinfo.c
+            perl -i -pe 's/^(\s*if \(inode\) \{)/$1\n        \/\*\n         * IN_ALL_EVENTS represents all of the mask bits\n         * that we expose to userspace.  There is at\n         * least one bit (FS_EVENT_ON_CHILD) which is\n         * used only internally to the kernel.\n         *\/\n        u32 mask = mark->mask & IN_ALL_EVENTS;/m' fs/notify/fdinfo.c
+            perl -i -pe 's/\binotify_mark_user_mask\(mark\)/mask, mark->ignored_mask/g' fs/notify/fdinfo.c
           fi
         fi
+
+
         if [ "${{ inputs.kernel_version }}" = "5.15" ] && [ "${{ inputs.android_version }}" = "android13" ]; then
           if [ "${{ inputs.sublevel }}" -le "43" ]; 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
+            perl -i -pe 's/^(\s*if \(inode\) \{)/$1\n        \/\*\n         * IN_ALL_EVENTS represents all of the mask bits\n         * that we expose to userspace.  There is at\n         * least one bit (FS_EVENT_ON_CHILD) which is\n         * used only internally to the kernel.\n         *\/\n        u32 mask = mark->mask & IN_ALL_EVENTS;/m' fs/notify/fdinfo.c
+            perl -i -pe 's/\binotify_mark_user_mask\(mark\)/mask, mark->ignored_mask/g' fs/notify/fdinfo.c
           fi
         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