-
Notifications
You must be signed in to change notification settings - Fork 436
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
Initialize field owner
in file_operations
(issue #214)
#228
Conversation
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.
Thanks!
Please note that this is taking the tuple constructor function and using its address as the owner. The Rust equivalent would be THIS_MODULE
(a per-module value), rather than ThisModule
(a type).
+1 Also note that |
Take module as an argument? It's a struct, not a function that can take arguments. What part of the code are you referring to? |
This struct is a private member of |
I can't take |
As far as I can see it, with the current implementation of FileOperationsVtable this is impossible. Const and const fn is evaluated at build time. But the address of THIS_MODULE can not be known then. A working way could be a proc_macro like I build for the rtnl_link_ops in #208 which then creates a static (mut) |
Could we change |
I don't have a solution for this yet, that's why I opened this bug... But the following are desirable aspects of an eventual solution:
(This is not a super easy task, apologies for not making it clear earlier.) |
Related: #212. |
174610c
to
d765c5e
Compare
Just pushed some code to the branch. The code obviously isn't done yet. The vtable isn't a constant and I had to remove the const keyword from the build function, as you cannot use those |
If the code isn't done yet, please mark it as a draft so that we only spend time reviewing it when it's done. Also, isn't the file_operations returned by |
d765c5e
to
d4bf48b
Compare
Oops - undone (The PR was closed until I push stuff to the branch for some reason) |
Fix for the issue #214
Struct
ThisModule
in lib.rs seems to be the equivalent of THIS_MODULE and according to this StackOverflow the owner field should be initialized to THIS_MODULE.Just point me to the right direction if this isn't the correct way to do it. I'm pretty new to contributing to the Linux kernel.