Вопрос

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.

Это было полезно?

Решение

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.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top