kernel module development: how to open block devices and use them (open, seek, read).
Linux - KernelThis forum is for all discussion relating to the Linux kernel.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I checked the values that IS_ERR returns. It's always 0. 0 before switching fs, after switching fs, after vfs_read and after switch back fs. How about that?
That means the "if" statement is not doing any tricks here, returning 0 means IS_ERR is not creating any problems which is a nice thing, now the next statement in that function is a call to vfs_read function, its declaration is shown in fs.h as: extern ssize_t vfs_read(struct file *, char __user *, size_t, loff_t *);
You need to verify whether the parameters you are throwing in it have exactly the same types as above, do they need a typecast. I haven't used vfs_read before, so you also need to see whether what these parameters mean is same as your understanding of them!
Quote:
Originally Posted by eantoranz
What technique could I apply so that I can handle this part in userspace?
You mean receiving the data from the device in user space? If yes, then you can read it in the kernel space and then "copy" it to the user space, there are predefined kernel functions for handling the same.
Quote:
Originally Posted by eantoranz
Also, wasn't there an addition to new kernels that is the equivalent of fuse but for block devices?
One thing I would like to clarify, I am no expert in these kernel matters. One year back I wrote the interrupt handlers for the keyboard and the serial port rs232, that's it. And secondly posting in the wrong forum is also not going to help you, "kernel section" post there.
Also: http://kernelnewbies.org/MailingList
I don't mean taking the whole driver to user space... just reading from the files so that I can skip this mess. I'll take a look at your link. Thank you very much.
Reading about call_usermodehelper_setup I'm wondering if it's possible to call an application and and communicate with it through its stdin/stdout? I'd like to keep implementation as simple as possible.
Other mechanism I found around is communicating through UDP. I was able to see messages sent from an application to the kernel, but I haven't been able to send information form the kernel to the outside world. Do you know of a simple example? Being able to send "hello world" through the net would be enough. Don't have to have a listening application on the other side to know that it's working.
I haven't used/read about the function you mentioned.
Quote:
Originally Posted by eantoranz
I'm wondering if it's possible to call an application and and communicate with it through its stdin/stdout?
Do you mean to ask whether it is possible to pass arguments to a kernel module?
Which application are you asking about?
Quote:
Originally Posted by eantoranz
but I haven't been able to send information form the kernel to the outside world. Do you know of a simple example? Being able to send "hello world" through the net would be enough.
Sending information from kernel to outside world means what? I don't understand sending "hello world through net".
Is all this related to the driver errors? If no, then there should be a new thread for a new problem.
P.S. Did you verify vfs_read as I mentioned in post 31?
I've been following the inner workings of the kernel when I call vfs_read (by cloning function, adding my debug messages, recompiling and so on). The error (one of the possible errors, that is...) is being generated on file->f_ops->read() from vfs_read(). How can I know where that function is going? By the fs? I mean, if the file is being read from an ext3 partition, I'd check the function used to read files on ext3 and so on?
Hi,eantoranz.
I know this thread is very old, but did you manage to read block device data from kernel module?
Or maybe anybody else know answer to that question?
Thanks.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.