Skip to content

Commit

Permalink
throne_tracker: Fix Manager sometimes not detecting KSU and optimize …
Browse files Browse the repository at this point in the history
…it (#1586)

The original logic was wrong and used 3 strlen()s for every file found,
wasting cpu.

Optimize it by first comparing only the filename length, given we
already know it,
and then strncmp() to compare with "base.apk"

Tested successfully on my Bandido Kernel (4.19)
  • Loading branch information
bemerguy authored Apr 3, 2024
1 parent a34090b commit 4f9bbf1
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions kernel/throne_tracker.c
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,7 @@ FILLDIR_RETURN_TYPE my_actor(struct dir_context *ctx, const char *name,
iterate_dir(file, &sub_ctx.ctx);
filp_close(file, NULL);
} else {
if ((strlen(name) == strlen("base.apk")) &&
(strncmp(name, "base.apk", strlen("base.apk")) == 0)) {
if ((namelen == 8) && (strncmp(name, "base.apk", namelen) == 0)) {
bool is_manager = is_manager_apk(dirpath);
pr_info("Found base.apk at path: %s, is_manager: %d\n",
dirpath, is_manager);
Expand Down

0 comments on commit 4f9bbf1

Please sign in to comment.