Skip to content

Fix build #54: FINAL umount -> sys_umount fix for kernel 4.9 - #32

Merged
Crybyte merged 2 commits into
mainfrom
fix/build-54-umount-final
Mar 28, 2026
Merged

Fix build #54: FINAL umount -> sys_umount fix for kernel 4.9#32
Crybyte merged 2 commits into
mainfrom
fix/build-54-umount-final

Conversation

@Crybyte

@Crybyte Crybyte commented Mar 28, 2026

Copy link
Copy Markdown
Owner

Automated fix for crDroid++ kernel build failure.

Issue: Build #53 failed with undefined reference to 'umount' at line 566

Root Cause:

  • The pre-patched core_hook.c.patched file is applied AFTER v38 fix scripts run
  • This overwrites any umount() -> sys_umount() replacements made by v38
  • The resulting file still calls umount() which doesn't exist in kernel 4.9

Fix:

  • Added fix_kernelsu_49_v39.py with aggressive umount() -> sys_umount() replacement
  • Updated workflow to run v39 AFTER the pre-patched file is applied
  • v39 ensures ALL umount() calls are replaced with sys_umount(path, 0)
  • Also adds sys_umount declaration for kernel 4.9 compatibility

Changes:

  • New file: build-scripts/fix_kernelsu_49_v39.py (aggressive regex-based replacement)
  • Modified: .github/workflows/crdroid-plus-kernel-build.yml (runs v39 after pre-patched file)

Related: Build #54 (attempt #54 overall, #53 failed with umount error)

cc: @coderabbitai

Summary by CodeRabbit

  • Chores
    • Added an extra automated fix step to the kernel build pipeline that runs a maintenance utility during builds.
    • Introduced a standalone CLI maintenance script that locates and updates affected kernel source files, applies targeted textual fixes, ensures required declarations exist, and prints a per-file status summary.

The pre-patched core_hook.c.patched file contains umount() calls
that don't exist in kernel 4.9. This fix adds a v39 script that runs
AFTER the pre-patched file is applied to ensure ALL umount() calls
are replaced with sys_umount().

Issue: Build #53 failed with undefined reference to 'umount' at line 566
Root Cause: Pre-patched file overwrites v38 fixes
Solution: Run v39 fix after pre-patched file application

Changes:
- Added fix_kernelsu_49_v39.py with aggressive umount() replacement
- Updated workflow to run v39 after pre-patched file application
- Ensures sys_umount declaration is added for kernel 4.9
@coderabbitai

coderabbitai Bot commented Mar 28, 2026

Copy link
Copy Markdown

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

Adds a CI workflow step and a new Python fixer that scans kernel source for drivers/kernelsu/core_hook.c, aggressively rewrites umount(...) to sys_umount(..., 0), inserts a sys_umount declaration if missing, and the workflow includes a repo-root fallback that alters the kernel-dir path used for the script.

Changes

Cohort / File(s) Summary
Workflow update
​.github/workflows/crdroid-plus-kernel-build.yml
Inserted "CRITICAL FIX v39" step that runs fix_kernelsu_49_v39.py preferentially from build-scripts/, with a fallback to the repo root; fallback uses a different kernel-dir path variant (~/kernel_build/... vs ~/kernel-build/...) when invoking the script.
KernelSU v39 fixer script
build-scripts/fix_kernelsu_49_v39.py
New CLI Python script that finds core_hook.c files in a kernel dir, de-duplicates by realpath, performs aggressive regex replacements changing unprefixed umount(X) to sys_umount(X, 0), reports remaining umount( occurrences, and inserts an asmlinkage long sys_umount(const char __user *name, int flags); declaration after the last #include if absent.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐰 I hopped through code and found a trace,
umounts reborn with a sys_ embrace,
a declaration snug after includes' line,
v39 marched in—now the kernel will shine! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 75.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly and clearly summarizes the main change: a final fix for umount to sys_umount conversion for kernel 4.9 compatibility, which aligns with the primary objective of resolving Build #54.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/build-54-umount-final

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.github/workflows/crdroid-plus-kernel-build.yml:
- Around line 447-450: The fallback invocation passes the wrong path string
(uses ~/kernel_build with an underscore) which will fail to locate the kernel
tree; update the command that runs fix_kernelsu_49_v39.py so the directory
argument and KERNEL_DIR environment value use the correct hyphenated path
(~/kernel-build/android_kernel_oneplus_sdm845) to match the rest of the workflow
and ensure core_hook.c files are found.

In `@build-scripts/fix_kernelsu_49_v39.py`:
- Around line 89-119: The function process_core_hook_files currently iterates
possible_paths and may process the same real file multiple times; change it to
deduplicate by tracking resolved real paths (e.g., a seen set) before processing
each entry: after computing real_path, skip the iteration if real_path is
already in seen, otherwise add real_path to seen and proceed with
aggressive_umount_fix and ensure_sys_umount_declaration, ensuring results only
contain one tuple per real_path; reference process_core_hook_files,
possible_paths, real_path, results, aggressive_umount_fix and
ensure_sys_umount_declaration when making the change.
- Around line 147-151: The loop unpacks (path, fixed, declared) from results but
never uses declared; update the summary inside the for loop (the for path,
fixed, declared in results block) to include declaration info — e.g. compute
status = "FIXED" if fixed else "OK" and append ", DECLARED" when declared is
truthy (or similar like status += " (declared)" ), then print f"  [{status}]
{path}"; alternatively if you intentionally discard declared, rename the third
unpack to _declared to signal it's unused (change for path, fixed, declared in
results to for path, fixed, _declared in results).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: def65740-7967-46cb-81ec-f861a5781b42

📥 Commits

Reviewing files that changed from the base of the PR and between c2c389e and f59dd7e.

📒 Files selected for processing (2)
  • .github/workflows/crdroid-plus-kernel-build.yml
  • build-scripts/fix_kernelsu_49_v39.py
📜 Review details
🧰 Additional context used
🪛 Ruff (0.15.7)
build-scripts/fix_kernelsu_49_v39.py

[warning] 23-23: Unnecessary mode argument

Remove mode argument

(UP015)


[warning] 54-54: Unnecessary else after return statement

Remove unnecessary else

(RET505)


[warning] 61-61: Unnecessary mode argument

Remove mode argument

(UP015)


[warning] 148-148: Loop control variable declared not used within loop body

Rename unused declared to _declared

(B007)


[warning] 153-153: Unnecessary else after return statement

Remove unnecessary else

(RET505)

🔇 Additional comments (2)
build-scripts/fix_kernelsu_49_v39.py (2)

17-55: LGTM! The regex pattern correctly fixes the lookbehind issue from v38.

The pattern (?<!sys_)(?<!try_)\bumount properly excludes already-prefixed calls, unlike v38's malformed (?<!)try_). The capture group and replacement logic are correct.

Minor style notes from static analysis (optional to address):

  • Line 23: open(file_path, 'r')open(file_path) (mode 'r' is default)
  • Line 54: else after return is unnecessary

58-86: LGTM! Declaration insertion logic is sound for kernel source files.

The check for existing declarations and insertion after the last #include is appropriate. Minor note: if no #include lines exist, insert_idx would be 0 (inserting at file start), but this is an unlikely edge case for kernel C files.

Comment thread .github/workflows/crdroid-plus-kernel-build.yml
Comment thread build-scripts/fix_kernelsu_49_v39.py
Comment thread build-scripts/fix_kernelsu_49_v39.py
- Fixed path typo: kernel_build -> kernel-build (underscore to hyphen)
- Added deduplication for core_hook.c file processing (seen_paths set)
- Renamed unused 'declared' variable to '_declared' to signal intentional discard
@Crybyte
Crybyte merged commit 0f59604 into main Mar 28, 2026
1 check was pending
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant