Uh oh!
There was an error while loading. Please reload this page.
Initialize field owner in file_operations (issue #214) - #228
Conversation
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).
wedsonaf
commented
Apr 26, 2021
+1 Also note that |
violetshine
commented
Apr 27, 2021
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? |
wedsonaf
commented
Apr 27, 2021
This struct is a private member of |
violetshine
commented
Apr 27, 2021
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) |
adamrk
commented
Apr 28, 2021
Could we change |
wedsonaf
commented
Apr 28, 2021
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.) |
ojeda
commented
Apr 28, 2021
Related: #212. |
violetshine
commented
Apr 28, 2021
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 |
wedsonaf
commented
Apr 28, 2021
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 |
violetshine
commented
Apr 28, 2021
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.