Initialize field owner in file_operations (issue #214)#228
Initialize field owner in file_operations (issue #214)#228violetshine wants to merge 0 commit intoRust-for-Linux:rustfrom
owner in file_operations (issue #214)#228Conversation
ojeda
left a comment
There was a problem hiding this comment.
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. |
|
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 |
|
Oops - undone (The PR was closed until I push stuff to the branch for some reason) |
Fix for the issue #214
Struct
ThisModulein 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.