Skip to content

Refactor module mount load in rust #8846

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Refactor module mount load in rust #8846

wants to merge 1 commit into from

Conversation

yujincheng08
Copy link
Collaborator

@yujincheng08 yujincheng08 commented Mar 10, 2025

Todo:

@yujincheng08 yujincheng08 force-pushed the module.rs branch 5 times, most recently from 36b06e7 to 515d7c5 Compare March 16, 2025 16:52
@yujincheng08 yujincheng08 marked this pull request as ready for review March 16, 2025 17:30
@topjohnwu topjohnwu added the next Planned for the release *after* the next release label Mar 19, 2025
@vvb2060
Copy link
Collaborator

vvb2060 commented Mar 20, 2025

where is #8790 ?

@yujincheng08
Copy link
Collaborator Author

@vvb2060 fixed

@yujincheng08 yujincheng08 requested a review from Copilot April 2, 2025 04:12
Copy link

@Copilot 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.

Pull Request Overview

This PR refactors the module mount load in Rust to build a module mount tree and support zygisk and magisk nodes, along with various mount operations.

  • Added new features and module support in native/src/core/lib.rs for deploying modules.
  • Modified error logging behavior in native/src/base/result.rs and improved file/dir operations in native/src/base/files.rs and native/src/base/dir.rs.
  • Introduced resize functionality in native/src/base/cstr.rs for both Utf8CString and FsPathBuf.

Reviewed Changes

Copilot reviewed 6 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
native/src/core/lib.rs Added a new C++ extern function deploy_modules and module import.
native/src/base/result.rs Changed log_ok function signature to return Option.
native/src/base/files.rs Updated libc constants and added functions for whiteout check and bind mounts.
native/src/base/dir.rs Updated directory open function with enhanced flags.
native/src/base/cstr.rs Added resize methods for Utf8CString and FsPathBuf.
Files not reviewed (2)
  • native/src/core/module.cpp: Language not supported
  • native/src/core/node.hpp: Language not supported
Comments suppressed due to low confidence (1)

native/src/core/lib.rs:245

  • [nitpick] Consider using a slice type (&[ModuleInfo]) instead of &Vec for improved flexibility and idiomatic Rust usage.
fn deploy_modules(module_list: &Vec<ModuleInfo>, zygisk_lib: &CxxString, magisk_path: &CxxString) -> bool;

Comment on lines +244 to +246
fn resize(&mut self, len: usize) {
if len >= self.0.capacity() {
return;
Copy link
Preview

Copilot AI Apr 2, 2025

Choose a reason for hiding this comment

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

The Utf8CString resize method silently returns if len is greater than or equal to capacity. It might be better to handle this case explicitly (e.g., by returning a Result or panicking) to avoid unintended behavior.

Suggested change
fn resize(&mut self, len: usize) {
if len >= self.0.capacity() {
return;
fn resize(&mut self, len: usize) -> Result<(), &'static str> {
if len >= self.0.capacity() {
return Err("Length exceeds capacity");

Copilot uses AI. Check for mistakes.

Comment on lines +602 to +605
unsafe {
self.0.as_bytes_mut()[len] = b'\0';
self.0.set_len(len)
};
Copy link
Preview

Copilot AI Apr 2, 2025

Choose a reason for hiding this comment

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

The FsPathBuf resize method lacks a bounds check on the provided len, which may lead to out-of-bound access. Consider adding a check to ensure len is within the valid range.

Suggested change
unsafe {
self.0.as_bytes_mut()[len] = b'\0';
self.0.set_len(len)
};
if len <= self.0.as_bytes().len() {
unsafe {
self.0.as_bytes_mut()[len] = b'\0';
self.0.set_len(len)
};
} else {
// Handle the error case, e.g., by returning self unchanged or logging an error
// For now, we will just return self unchanged
}

Copilot uses AI. Check for mistakes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
next Planned for the release *after* the next release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants