From 7cc8108c44b3451ad1fd5d8dc4ab6a467fb99e3f Mon Sep 17 00:00:00 2001 From: backslashxx <118538522+backslashxx@users.noreply.github.com> Date: Sun, 17 Mar 2024 17:09:40 +0800 Subject: [PATCH] kernel: suggest non-gki kernel users to backport path_umount Most non-gki kernel builders have to touch their kernel source code anyway. Tell them to backport path_umount, spread the news so they can benefit. Discussion: https://github.com/tiann/KernelSU/pull/1464 Co-Authored-By: Fede2782 <78815152+Fede2782@users.noreply.github.com> Co-Authored-By: backslashxx <118538522+backslashxx@users.noreply.github.com> Co-Authored-By: Tom <31297720+onlytominsecond@users.noreply.github.com> --- kernel/Makefile | 7 +++++++ kernel/core_hook.c | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/kernel/Makefile b/kernel/Makefile index f8dff4d6cc71..fcc58a5bd9a5 100644 --- a/kernel/Makefile +++ b/kernel/Makefile @@ -62,6 +62,13 @@ $(info -- KernelSU Manager signature hash: $(KSU_EXPECTED_HASH)) ccflags-y += -DEXPECTED_SIZE=$(KSU_EXPECTED_SIZE) ccflags-y += -DEXPECTED_HASH=\"$(KSU_EXPECTED_HASH)\" +ifeq ($(shell grep -q "int path_umount" $(srctree)/fs/namespace.c; echo $$?),0) +ccflags-y += -DKSU_UMOUNT +else +$(info -- Did you know you can backport path_umount to fs/namespace.c from 5.9?) +$(info -- Read: https://kernelsu.org/guide/how-to-integrate-for-non-gki.html#path_umount) +endif + ccflags-y += -Wno-implicit-function-declaration -Wno-strict-prototypes -Wno-int-conversion -Wno-gcc-compat ccflags-y += -Wno-declaration-after-statement -Wno-unused-function diff --git a/kernel/core_hook.c b/kernel/core_hook.c index dfb4d3f6206e..06fc75cfffc6 100644 --- a/kernel/core_hook.c +++ b/kernel/core_hook.c @@ -513,7 +513,7 @@ static bool should_umount(struct path *path) static void ksu_umount_mnt(struct path *path, int flags) { -#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 9, 0) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 9, 0) || KSU_UMOUNT int err = path_umount(path, flags); if (err) { pr_info("umount %s failed: %d\n", path->dentry->d_iname, err);