Re: kernel modules

Richard B. Johnson (root@chaos.analogic.com)
Wed, 1 Dec 1999 12:49:00 -0500 (EST)


On Wed, 1 Dec 1999 prakash@rnd.cts-corp.com wrote:

> Hi all,
>
> How do i read and write to a file from a kernel module.?? I am trying to
> write a module, which on intializing will read over through a flat file
> and store the contents of file in some data structure.
>
> bye,
> prakash

You don't and it's not necessary. You use the module's ioctl() function
(which you define) to take data from a user-mode program when you want
to start the module.

Trivial case:

cprogram()
{
system("insmod my_module");
fd = open("/my/device", O_WHATEVER);
ioctl(fd, INSERT_MY_DATA, buffer);
ioctl(fd, TEST_MY_DEVICE, &results);
close(fd);
}

Cheers,
Dick Johnson

Penguin : Linux version 2.3.13 on an i686 machine (400.59 BogoMips).
Warning : It's hard to remain at the trailing edge of technology.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/