Skip to content

Split monolithic jailbreak.c into reusable shared modules#2

Draft
Copilot wants to merge 3 commits intomasterfrom
copilot/split-into-reusable-components
Draft

Split monolithic jailbreak.c into reusable shared modules#2
Copilot wants to merge 3 commits intomasterfrom
copilot/split-into-reusable-components

Conversation

Copy link
Copy Markdown

Copilot AI commented Apr 4, 2026

jailbreak.c was a 3000+ line monolith with several helper functions copy-pasted verbatim across tools/mb2insert.c, tools/injectconf.c, src/idevicebackup2.c, and src/afc.c. This extracts those duplicates into proper shared modules.

New modules

src/afc_utils.c/h — AFC helpers

Consolidates 5+ independent copies of the same functions:

  • afc_dictionary_free() — replaces free_dictionary / afc_free_dictionary
  • afc_rmdir_recursive() — replaces rmdir_recursive_afc
  • afc_upload_file() / afc_upload_file_as() — extracted from jailbreak.c only

src/vpn_config.c/h — VPN on-demand configuration

Consolidates 4+ independent copies:

  • vpn_prefs_remove_entry() — replaces prefs_remove_entry_if_present
  • vpn_prefs_add_entry() — replaces prefs_add_entry
  • Centralises VPN_CONNECTION_NAME and VPN_TRIGGER_ADDRESS defines

src/device_compat.c/h — Device compatibility table

  • Moves devices_vmaddr_libcopyfile[] out of jailbreak.h (was incorrectly a static array in a header — each translation unit got its own copy)
  • Moves compatible_devices[], get_libcopyfile_vmaddr(), jb_device_is_supported(), jb_check_consistency(), verify_product(), check_consistency() out of jailbreak.c

Updated callers

src/jailbreak.c, src/jailbreak.h, src/afc.c, src/idevicebackup2.c, tools/mb2insert.c, tools/injectconf.c, src/Makefile.am, tools/Makefile.am.

jailbreak.h keeps a CONNECTION_NAME alias pointing to VPN_CONNECTION_NAME for backward compatibility with any out-of-tree consumers.

Original prompt

How can we split this up into more reusable components and modules

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot wasn't able to review any files in this pull request.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copilot AI changed the title [WIP] Refactor code to split into reusable components Split monolithic jailbreak.c into reusable shared modules Apr 4, 2026
Copilot AI requested a review from posixninja April 4, 2026 19:04
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.

3 participants