You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fairly new with LKM's but I have a IOCtl function that is defined as _IORW(MAGIC, 1, struct mystruct *) and the LKM uses the pointer to read and to write to a field in the struct. According to [1] that means the function should be declared are RW.
_IO/_IOR/_IOW/_IOWR
The macro name specifies how the argument will be used. Â It may be a
pointer to data to be passed into the kernel (_IOW), out of the kernel
(_IOR), or both (_IOWR). Â _IO can indicate either commands with no
argument or those passing an integer value instead of a pointer.
It is recommended to only use _IO for commands without arguments,
and use pointers for passing data.
Looking at the issues, this is mentioned a couple of times and people give an implementation but it was never added. Is there any reason its not implemented? Considering the description in [1] I would expect all three variants:
ioctl_write_ptr
ioctl_read_ptr
ioctl_readwrite_ptr
but currently only ioctl_write_ptr is implemented.
Merge requests that add's it: #965
Question with someone offering a implementation: #1386 (comment)
Ok took some time. But think I under stand it now.
The read and readwrite functions always use a pointer, as else there is no other way to get a value back from the kernal driver. For the write this is different, as you can write a value like char/int/long as a direct parameters, or as a pointer to the value. So the distinction between the two is needed there.
@asomers My problem is fixed. Was planning on reading the documentation again to see if it could use an update to explain the situation with the write and write_ptr a bit better. But haven't had time for that....
Wat thrown me of is that the write_ptr function suggest that there should be a pointer variant for all the other types as well. But this is not the case, as they already use a pointer. (Maybe it would have been better to make the write variant accept a pointer, and to create a write_value version to keep the write macro in line with the other macro's).
Fairly new with LKM's but I have a IOCtl function that is defined as
_IORW(MAGIC, 1, struct mystruct *)
and the LKM uses the pointer to read and to write to a field in the struct. According to [1] that means the function should be declared are RW.Looking at the issues, this is mentioned a couple of times and people give an implementation but it was never added. Is there any reason its not implemented? Considering the description in [1] I would expect all three variants:
ioctl_write_ptr
ioctl_read_ptr
ioctl_readwrite_ptr
but currently only
ioctl_write_ptr
is implemented.Merge requests that add's it: #965
Question with someone offering a implementation: #1386 (comment)
[1] https://www.kernel.org/doc/Documentation/core-api/ioctl.rst
The text was updated successfully, but these errors were encountered: