From a4163f0df611ff4c598436c41d93161832d6841a Mon Sep 17 00:00:00 2001 From: backslashxx <118538522+backslashxx@users.noreply.github.com> Date: Fri, 21 Nov 2025 21:02:41 +0800 Subject: [PATCH 1/7] scripts/metainstall: handle symlinks --- template/metainstall.sh | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/template/metainstall.sh b/template/metainstall.sh index 9e299ee..a3306f6 100644 --- a/template/metainstall.sh +++ b/template/metainstall.sh @@ -18,4 +18,21 @@ handle_partition() { # call install function, this is important! install_module +mm_handle_partition() { + partition="$1" + + if [ ! -d "$MODPATH/system/$partition" ]; then + return + fi + + if [ -L "/system/$partition" ] && [ -d "/$partition" ]; then + ui_print "- Handle partition /$partition" + ln -sf "./system/$partition" "$MODPATH/$partition" + fi +} + +mm_handle_partition system_ext +mm_handle_partition vendor +mm_handle_partition product + ui_print "- Installation complete" From dc03845148259581e666da19ad5a7aded7f050ed Mon Sep 17 00:00:00 2001 From: backslashxx <118538522+backslashxx@users.noreply.github.com> Date: Fri, 21 Nov 2025 21:21:48 +0800 Subject: [PATCH 2/7] Makefile: some changes --- src/Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Makefile b/src/Makefile index df31864..c73fc36 100644 --- a/src/Makefile +++ b/src/Makefile @@ -13,13 +13,13 @@ SRCS := utils.c magic_mount.c main.c OUTDIR := bin # common flags -CFLAGS_COMMON := -D_POSIX_C_SOURCE=200809L -std=c23 -Wall -Wextra -pedantic +CFLAGS_COMMON := -Wl,--gc-sections -static CFLAGS_COMMON += -DVERSION=\"$(VERSION)\" LDFLAGS_COMMON := -static # build mode specific flags -CFLAGS_RELEASE := -O2 -DNDEBUG +CFLAGS_RELEASE := -Oz -s -DNDEBUG CFLAGS_DEBUG := -O0 -g -DDEBUG # zig target triples @@ -84,4 +84,4 @@ $(BIN_ARMV7): $(SRCS) $(CC) -target $(TARGET_ARMV7) $(CFLAGS) $^ -o $@ $(LDFLAGS_COMMON) clean: - rm -rf $(OUTDIR) \ No newline at end of file + rm -rf $(OUTDIR) From a88cda7f14f184cda83ec475a36e481e93cb6b9b Mon Sep 17 00:00:00 2001 From: backslashxx <118538522+backslashxx@users.noreply.github.com> Date: Fri, 21 Nov 2025 21:21:36 +0800 Subject: [PATCH 3/7] workflows: add simple workflow --- .github/workflows/compile.yml | 54 +++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 .github/workflows/compile.yml diff --git a/.github/workflows/compile.yml b/.github/workflows/compile.yml new file mode 100644 index 0000000..775a6e7 --- /dev/null +++ b/.github/workflows/compile.yml @@ -0,0 +1,54 @@ +name: build module + +on: + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout repo + uses: actions/checkout@v3 + + - name: grab zig + run: | + curl -L https://ziglang.org/download/0.15.2/zig-x86-linux-0.15.2.tar.xz -o zig.tar.xz + tar -xf zig.tar.xz + mv zig-* zig + + - name: grab sstrip from ELFkickers + run: | + curl -L https://www.muppetlabs.com/~breadbox/pub/software/ELFkickers-3.2.tar.gz -o sstrip.tar.gz + tar xf sstrip.tar.gz + make -C ELFkickers-3.2 sstrip + cp ELFkickers-3.2/sstrip/sstrip . + + - name: compile binary via zigcc + run: | + echo "arm, aarch64 and x86_64" + pwd + chmod +x sstrip ; mv sstrip strip + + PATH=$(pwd)/zig:$(pwd):$PATH + + cd src; make + + wc -c bin/mm_* + upx --ultra-brute bin/mm_* + + wc -c bin/mm_* + file bin/mm_* + + cd ../template + pwd + mkdir bin + pwd + mv -f ../src/bin/* bin/ + # how to handle this? + # mv -f ../webui webroot + + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: zip + path: template From 61f7ab30d523f50d21a323c85d3d4f0bc12d00e9 Mon Sep 17 00:00:00 2001 From: backslashxx <118538522+backslashxx@users.noreply.github.com> Date: Fri, 21 Nov 2025 21:49:53 +0800 Subject: [PATCH 4/7] Makefile: restore pedantic --- src/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Makefile b/src/Makefile index c73fc36..955d223 100644 --- a/src/Makefile +++ b/src/Makefile @@ -13,7 +13,7 @@ SRCS := utils.c magic_mount.c main.c OUTDIR := bin # common flags -CFLAGS_COMMON := -Wl,--gc-sections -static +CFLAGS_COMMON := -Wl,--gc-sections -static -Wpedantic -Werror CFLAGS_COMMON += -DVERSION=\"$(VERSION)\" LDFLAGS_COMMON := -static From ae87f306800fa9e29905fc0cad37470f138ced50 Mon Sep 17 00:00:00 2001 From: backslashxx <118538522+backslashxx@users.noreply.github.com> Date: Fri, 21 Nov 2025 21:01:37 +0800 Subject: [PATCH 5/7] magic_mount: tell ksu about our mounts --- src/magic_mount.c | 30 +++++++++++++++++++++++++++++- src/magic_mount.h | 13 +++++++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/src/magic_mount.c b/src/magic_mount.c index 1c10207..edae7d9 100644 --- a/src/magic_mount.c +++ b/src/magic_mount.c @@ -14,6 +14,8 @@ #include #include #include +#include +#include MountStats g_stats = { 0 }; @@ -26,6 +28,25 @@ int g_failed_modules_count = 0; char **g_extra_parts = NULL; int g_extra_parts_count = 0; +int global_fd = 0; + +static void grab_fd(void) { syscall(SYS_reboot, KSU_INSTALL_MAGIC1, KSU_INSTALL_MAGIC2, 0, (void *)&global_fd); } + +static void send_unmountable(const char *mntpoint) +{ + struct ksu_add_try_umount_cmd cmd = {0}; + + if (!global_fd) + return; + + cmd.arg = (uint64_t)mntpoint; + cmd.flags = 0x2; + cmd.mode = 1; + + ioctl(global_fd, KSU_IOCTL_ADD_TRY_UMOUNT, &cmd); + +} + static void register_module_failure(const char *module_name) { if (!module_name) @@ -496,7 +517,8 @@ static int do_magic(const char *base, const char *wbase, Node *node, LOGE("bind %s->%s: %s", node->module_path, target, strerror(errno)); return -1; - } + } else + send_unmountable(target); // tell ksu about this mount (void)mount(NULL, target, NULL, MS_REMOUNT | MS_BIND | MS_RDONLY, NULL); @@ -704,6 +726,10 @@ static int do_magic(const char *base, const char *wbase, Node *node, LOGI("move mountpoint success: %s -> %s", wpath, path); (void)mount(NULL, path, NULL, MS_REC | MS_PRIVATE, NULL); + + // tell ksu about this one too + send_unmountable(path); + } g_stats.nodes_mounted++; @@ -800,6 +826,8 @@ int magic_mount(const char *tmp_root) node_free(root); return -1; } + + grab_fd(); LOGI("starting magic_mount core logic: tmpfs_source=%s tmp_dir=%s", g_mount_source, tmp_dir); diff --git a/src/magic_mount.h b/src/magic_mount.h index a3e8e69..9710d7c 100644 --- a/src/magic_mount.h +++ b/src/magic_mount.h @@ -2,6 +2,7 @@ #define MAGIC_MOUNT_H #include +#include #define DISABLE_FILE_NAME "disable" #define REMOVE_FILE_NAME "remove" @@ -36,4 +37,16 @@ int magic_mount(const char *tmp_root); void add_extra_part_token(const char *start, size_t len); +// kernelsu api, atleast ones we care about +#define KSU_INSTALL_MAGIC1 0xDEADBEEF +#define KSU_INSTALL_MAGIC2 0xCAFEBABE + +struct ksu_add_try_umount_cmd { + uint64_t arg; // char ptr, this is the mountpoint + uint32_t flags; // this is the flag we use for it + uint8_t mode; // denotes what to do with it 0:wipe_list 1:add_to_list 2:delete_entry +}; + +#define KSU_IOCTL_ADD_TRY_UMOUNT _IOC(_IOC_WRITE, 'K', 18, 0) + #endif /* MAGIC_MOUNT_H */ From 3588ef9e9e06aedf690b7f6afc8d0eb1b3c6489e Mon Sep 17 00:00:00 2001 From: backslashxx <118538522+backslashxx@users.noreply.github.com> Date: Fri, 21 Nov 2025 21:32:16 +0800 Subject: [PATCH 6/7] scripts/metamount: tell ksud about it --- template/metamount.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/template/metamount.sh b/template/metamount.sh index c9e1f6b..c4d9584 100644 --- a/template/metamount.sh +++ b/template/metamount.sh @@ -34,10 +34,11 @@ $BINARY EXIT_CODE=$? -if [ $EXIT_CODE -ne 0 ]; then +if [ "$EXIT_CODE" = 0 ]; then + /data/adb/ksud kernel notify-module-mounted + log "Mount completed successfully" +else log "Mount failed with exit code $EXIT_CODE" - exit $EXIT_CODE fi -log "Mount completed successfully" exit 0 From 38f0a8888e40482502d2e04853e6cfe99d53d29d Mon Sep 17 00:00:00 2001 From: 7a72 <11066204+7a72@users.noreply.github.com> Date: Fri, 21 Nov 2025 22:08:17 +0800 Subject: [PATCH 7/7] Update compile.yml --- .github/workflows/compile.yml | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/.github/workflows/compile.yml b/.github/workflows/compile.yml index 775a6e7..fd76773 100644 --- a/.github/workflows/compile.yml +++ b/.github/workflows/compile.yml @@ -9,6 +9,14 @@ jobs: steps: - name: Checkout repo uses: actions/checkout@v3 + - name: Install pnpm + uses: pnpm/action-setup@v4 + with: + version: 10 + - uses: actions/setup-node@v6 + with: + node-version: 22 + cache: pnpm - name: grab zig run: | @@ -23,6 +31,12 @@ jobs: make -C ELFkickers-3.2 sstrip cp ELFkickers-3.2/sstrip/sstrip . + - name: webui + run: | + cd webui + pnpm i + pnpm build + - name: compile binary via zigcc run: | echo "arm, aarch64 and x86_64" @@ -44,8 +58,6 @@ jobs: mkdir bin pwd mv -f ../src/bin/* bin/ - # how to handle this? - # mv -f ../webui webroot - name: Upload artifact uses: actions/upload-artifact@v4