Skip to content
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

Refactor Path and FD Conversion Logic into Reusable Helper Functions #77

Open
Yaxuan-w opened this issue Jan 6, 2025 · 2 comments
Open
Labels
good first issue Good for newcomers RawPOSIX RawPOSIX related issue

Comments

@Yaxuan-w
Copy link
Member

Yaxuan-w commented Jan 6, 2025

While expanding readlink / readlinkat, I noticed that we often repeat similar conversion logic in multiple places within fs_calls and net_calls. This includes conversions between user-view paths and host kernel paths, as well as between virtual file descriptors and kernel file descriptors. Simplifying this process with reusable helper functions could make the codebase cleaner and easier to maintain.

Currently, the conversion logic is scattered and duplicated across various parts of fs_calls and net_calls. By consolidating this logic into well-designed helper functions, we can reduce redundancy, improve code clarity, and streamline future development. Additionally, this task provides a great entry point for new contributors to understand the project structure.

@Yaxuan-w Yaxuan-w added good first issue Good for newcomers RawPOSIX RawPOSIX related issue labels Jan 6, 2025
@Yaxuan-w
Copy link
Member Author

Yaxuan-w commented Jan 7, 2025

Thanks to Matt for pointing out this issue during the code review!

In current RawPOSIX design, let relative_path = relpath.to_str().unwrap(); would panic if the path variable containing non-utf-8 characters. To avoid this, we should implement a better error handling (e.g., using return EINVAL instead of .unwrap()), which I think could be done in our following refactor.

@rennergade
Copy link
Contributor

I think it would be good to combine removing filesystem.rs into whatever this PR becomes. Most of that has been stripped from the RustPOSIX days and now is only like 2 tools for path conversions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers RawPOSIX RawPOSIX related issue
Projects
None yet
Development

No branches or pull requests

2 participants