- From: Calin A. Culianu <calin_at_ajvar.org>
- Date: Thu, 19 Sep 2002 18:57:33 -0400 (EDT)
On Wed, 18 Sep 2002, Guenter Gebhardt wrote: > On Wednesday 18 September 2002 10:36, you wrote: > > On Wed, Sep 18, 2002 at 09:56:55AM +0200, Guenter Gebhardt wrote: > > > Hello, > > > > > > I want to access a file on the hard disk with firmware from driver code, > > > in order to load it into a device during device initialization. > > > > You can't. See the -i option in comedi_config to load firmware. > > Is this only true for modules programmed to fit into the comedi driver, or is > it generally not possible for kernel code to access a file on the hard disk? > It is definitely possible, although a bit more involved that the simple open()/read() combination you have in userspace. Some might say that it is even "bad bad bad" to do that, but, well, what is open source software if not the freedom to do what you want with your code? At any rate I tend to think that you are better off doing something similar to what comedi does to give files to the kernel via copying data to/from userspace, but you can try looking into the way the sys_open() and sys_read() system calls are written. You have to do a path_init() and then a path_walk() to get a struct nameidata, then you take the inode in the nameidata and call inode->i_fop->read() for that inode. However, I could be wrong. I fear that read() for an inode assumes that you are reading into a userspace buffer... in which case I have no idea how to accomplish the actual read... :( It may be programmatically simpler to get the information over to the driver via some mechanism like an ioctl() (or a write()) for a custom device node you create, since then you can just copy_from_user(), but that requires cooperation from userspace. -Calin
Received on 2002-09-19Z21:57:33