Skip to content

seq_file.rs: Borrow data from C pointer #394

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

Closed
wants to merge 3 commits into from

Conversation

adamrk
Copy link

@adamrk adamrk commented Jun 29, 2021

Borrow the seq_file data from the C pointer using PointerWrapper::borrow instead of taking ownership and then using mem::forget. This contains the changes of #232.

Note: I've added UnsafeReference to the kernel module's public interface because the doctest example for seq_file wraps the data in a Box. This means the user is going to need to extract the data from <Box as PointerWrapper>::Borrow which is UnsafeReference. Was it intentional that for UnsafeReference to not be public?

adamrk added 3 commits June 29, 2021 00:10
Adds a trait which allows Rust modules to implement the seq_operations
interface and use it to create a `/proc` file.

Signed-off-by: Adam Bratschi-Kaye <[email protected]>
Signed-off-by: Adam Bratschi-Kaye <[email protected]>
Instead of taking ownership of the data from the C side, borrow it
using the new `PointerWrapper` interface.

Signed-off-by: Adam Bratschi-Kaye <[email protected]>
@adamrk adamrk mentioned this pull request Jun 29, 2021
@ksquirrel
Copy link
Member

Review of 55813d497b79:

  • ⚠️ This PR changes more than 20 files.
  • ⚠️ This PR adds/deletes more than 500 lines.
  • ✔️ Commit 4f0aeff: Looks fine!
  • ✔️ Commit 2fc05b5: Looks fine!
  • ✔️ Commit 55813d4: Looks fine!

@TheSven73
Copy link
Collaborator

Hi Adam, what is the goal here? Is this so Rust kernel components (drivers, fses, etc) can create procfs entries? I believe that procfs has been deprecated for quite some time, i.e. no new kernel components may add to procfs - but I could be wrong. Do you need this for anything specific?

@adamrk
Copy link
Author

adamrk commented Jul 3, 2021

Hi Adam, what is the goal here? Is this so Rust kernel components (drivers, fses, etc) can create procfs entries? I believe that procfs has been deprecated for quite some time, i.e. no new kernel components may add to procfs - but I could be wrong. Do you need this for anything specific?

Yes that's the goal. I don't need it for anything specific, more just trying out how wrapping some kernel APIs would work and figured someone might want it at some point. I was planning to add support for debugfs entries using seq_file as a follow up - do you think I should just get rid of the procfs stuff and only support debugfs?

@adamrk
Copy link
Author

adamrk commented Feb 28, 2022

redoing this

@adamrk adamrk closed this Feb 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants