-
Notifications
You must be signed in to change notification settings - Fork 13.7k
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
base: master
Are you sure you want to change the base?
Conversation
36b06e7
to
515d7c5
Compare
where is #8790 ? |
@vvb2060 fixed |
There was a problem hiding this 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;
fn resize(&mut self, len: usize) { | ||
if len >= self.0.capacity() { | ||
return; |
There was a problem hiding this comment.
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.
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.
unsafe { | ||
self.0.as_bytes_mut()[len] = b'\0'; | ||
self.0.set_len(len) | ||
}; |
There was a problem hiding this comment.
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.
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.
Todo: