Is it possible to use ioctl inside a kernel module? Or is there any good solutions for this
Asked
Active
Viewed 38 times
0
-
It might be possible, but no driver does this or would do this. – stark Jul 22 '22 at 13:25
-
Do you recommend any other approach for this – Hoang Do Jul 22 '22 at 13:30
-
2Don't make one driver dpendent on another driver. It means you are putting code in the kernel which is unrelated to the driver function. – stark Jul 22 '22 at 13:31
-
@Tsyvarev I don't think that will work for recent kernel versions. `set_fs` has been gradually removed from architectures since 5.10, with complete removal in 5.18. – Ian Abbott Jul 25 '22 at 16:18
-
@IanAbbott: Yes, in the absence of `set_fs` the list of ioctl identifiers usable from the kernel is heavily reduced. But there is no other alternative. Only some "generic" ioctls, which doesn't envolve specific driver, has their "exported" variant, they can be found in the [fs/ioctl.c](https://elixir.bootlin.com/linux/v5.18.14/source/fs/ioctl.c) by searching for `EXPORT_SYMBOL` usages. – Tsyvarev Jul 25 '22 at 17:12
-
"Do you recommend any other approach for this"? If both modules are under your control, you can provide kernel interfaces to completely bypass the file operations. – Ian Abbott Jul 26 '22 at 09:19
-
@IanAbbott, even if it's not, in many cases frameworks allow you to find a proper device (driver) and call operations on it. – 0andriy Jul 30 '22 at 12:18