Commit Graph
37 Commits
Author SHA1 Message Date
topjohnwu 66bcdaf4e0 magiskboot: support building on host
Allow magiskboot to be built directly on host platforms (macOS and
Linux) using Cargo:
- Add a binary target to boot module with a no_main entry point that
  directly reuses the C main CLI implementation.
- Compile native C and C++ sources (base, boot, cxx, and lz4) via cc in
  base and boot build.rs when target_os is not Android.
- Platform gate Linux-specific functionality (SELinux xattrs, mount,
  namespaces) in base on Linux and Android, and provide macOS fallback
  for xsendfile.
- Move MountInfo and mount parsing from files to mount module.
- Scope Android-specific LTO rustflags in config.toml to Android
  targets.
- Ensure build.py compiles Rust modules as static libraries (--lib).

Assisted-by: Gemini 3.8 Flash
2026-10-02 17:17:48 -07:00
topjohnwu 33d09a2aff Expose xpipe2 as symbol 2026-10-02 17:17:48 -07:00
topjohnwu 8348d6e39c base: eliminate /proc/self/fd path resolution
Remove reliance on /proc/self/fd symlink resolution across base and core
components:
- Add top-level pre_order_walk and post_order_walk that track entry
  paths via an internal buffer, and unify Directory walk methods to
  support path-tracking and pathless traversals without extra overhead.
- Add DirEntry::get_stat using fstatat(AT_SYMLINK_NOFOLLOW) directly on
  directory file descriptors.
- Update Directory::copy_into and link_into to operate directly on file
  descriptors with fd_get_attr/fd_set_attr, passing paths only for
  symlink attribute updates.
- Refactor find_apk_path and restore_tmpcon to use pre_order_walk, and
  update get_app_no_list to use DirEntry::get_stat.
- Remove DirEntry::resolve_path, Directory::path_at,
  Directory::resolve_path, and fd_path.
- Replace remaining consumers of xrealpath and canonical_path (in su
  and magiskinit) with standard realpath or partition matching, allowing
  removal of Utf8CStr::realpath and its C FFI exports.

Assisted-by: Gemini 3.8 Flash
2026-10-02 17:17:48 -07:00
topjohnwu 01cb75eaef Code cleanup 2025-12-13 22:12:30 -08:00
topjohnwu 3cda9beb93 Cleanup unused bindings 2025-09-24 02:38:18 -07:00
topjohnwu ef4e230258 Use nix for libc functions 2025-09-08 23:59:29 -07:00
topjohnwu 1df5b34175 Stop differentiate Error vs ErrorCxx 2025-09-08 11:25:18 -07:00
topjohnwu ea5fe7525d Simplify LibcReturn 2025-09-08 10:55:57 -07:00
topjohnwu b861671391 Cleanup libbase 2025-08-25 01:31:47 -07:00
topjohnwu 3327fc668e Remove FsPath and FsPathMnt trait
Directly use Utf8CStr
2025-04-28 17:22:14 -07:00
topjohnwu e02b5f7868 Rename cstr_buf to cstr::buf 2025-04-22 03:21:00 -07:00
topjohnwu f3fef7bfe4 Make FsPath a trait 2025-04-22 03:21:00 -07:00
topjohnwu 55b036c071 Introduce BorrowedDirectory 2025-04-15 10:26:22 -07:00
topjohnwu 30e79310ab Make pointers NonNull after error check 2025-04-15 00:18:48 -07:00
topjohnwu f063fa5054 Cleanup xwrap implementation 2025-04-15 00:18:48 -07:00
topjohnwu 95d3eac2e0 Cleanup xwrap functions 2025-03-09 01:10:41 -08:00
topjohnwu c90e73ccec Migration to Edition 2024 2025-03-07 02:35:25 -08:00
topjohnwu 1eddbfd72c Use const_format for const strings 2024-03-26 18:03:40 -07:00
topjohnwu 36de62873a Fix error logging on the C++ side 2023-10-13 16:59:54 -07:00
topjohnwu 6e7a995716 Introduce UtfCString 2023-09-27 15:21:24 -07:00
topjohnwu a55d570213 Move more I/O operations into Rust 2023-09-27 02:28:43 -07:00
topjohnwu 15e13a8d8b Organize logging code 2023-09-19 03:02:30 -07:00
topjohnwu 8e1a91509c Remove readlink_unsafe 2023-09-19 00:06:21 -07:00
topjohnwu 89aee6ffa7 Add more to the Utf8CStr family
Better C strings with path operations
2023-09-12 17:35:01 -07:00
topjohnwu 9638dc0a66 Fix perror 2023-07-25 21:03:04 -07:00
topjohnwu e8e8afa6c2 Properly handle visibility 2023-07-06 11:12:27 -07:00
topjohnwu 4ee4cbada6 Standardize logging and error handling
- Introduce new types: LoggedResult and LoggedError
- Introduce new extension methods to log and add additional msgs
- Never exit when logging error messages in Rust (all errors should be
  handled by using Result and Rust's error propagation)
- Remove all usages of anyhow as it doesn't fit Magisk's use cases
2023-06-29 17:14:53 -07:00
topjohnwu cb3ab63815 Replace all CStr usage to Utf8CStr 2023-06-12 13:57:15 -07:00
topjohnwu 40f25f4d56 Introduce directory traversal 2023-06-09 02:00:37 -07:00
topjohnwu 9ea9f01933 Resolve clippy errors and warnings 2023-05-31 01:08:33 -07:00
topjohnwu 44643ad7b3 Restrict pointer aliasing
Close #6354, close #6353
2022-10-31 16:35:33 -07:00
topjohnwu 48f829b76e Minor refactoring 2022-09-21 03:09:46 +02:00
topjohnwu af99c1b843 Don't crash when nullptr paired with len = 0 2022-09-15 16:56:22 -07:00
topjohnwu c6646efe68 Move all xwrap to Rust 2022-09-15 01:17:05 -07:00
topjohnwu 34dd9eb7d6 More Rust 2022-08-19 02:21:52 -07:00
topjohnwu 4d9b7e7114 More Rust 2022-08-15 11:53:51 -07:00
topjohnwu 4c0f72f68f Move part of libbase to Rust 2022-08-08 22:53:37 -07:00