Question

In my project I have to fill my buffer with data from specified input (/dev/urandom by default). I googled it how to open and read data in kernel space from character device, but the forums are about how to implement the read function of my own character device, or how to read (regular?) files (which is not recommended according to this article). My question is, if there any simpler way to read data from specified chardev, or I have to use this sysfs file system? For me it's quite confusing, and I've decided to ask before I write hundreds of lines.

Était-ce utile?

La solution

As far as I understood, there's no easy and correct way to read files from kernel space.

Since in my project this file read is provisional only for test purposes, it's okay to read file the "ugly" way, described in the article in the question. If the release version of the kernel module uses such file interactions, that's unacceptable.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top