f



Communicating Data from User Space to Kernel Space

struct rule{
        int proto;
         char source[15];
       }instance;

I have written this structure into a file in user space ,say rule.txt .
Say this file contains 10 records , i. e 10 instances of the above
structure.Now I would like to read the same file in kernel space by a
kernel module by reading 1 record at a time. How can i do this ?

Is there any other way to do this without using files ?  My objective
is to read the 10 records from kernel  space one record at a time and
not the individual bytes.

0
amit
9/10/2006 11:43:09 AM
comp.linux.development.system 5436 articles. 0 followers. zixenus (12) is leader. Post Follow

4 Replies
410 Views

Similar Articles

[PageSpeed] 58

amit wrote:
> 
> Is there any other way to do this without using files ?  My objective
> is to read the 10 records from kernel  space one record at a time and
> not the individual bytes.
> 

hello

For example, you can use netlink to communicate between user- and
kernelspace, or you create an entry in the proc filesystem and use
ioctl (but it isn't the prefered way). Or you use a device.

Instead of using netlink, try out connector which is based on netlink
but smarter to use.

If you use netlink or connector you have to write a usermode helper
application which sends all the data (packet for packet) to the kernel.

hth

Marco
0
Marco
9/10/2006 3:20:50 PM
The best way is to use Netlink, as it is socket, it can be easily
modified to adapt if your server is not resides in kernel (such as
another machine).

ABAI
amit wrote:
> struct rule{
>         int proto;
>          char source[15];
>        }instance;
>
> I have written this structure into a file in user space ,say rule.txt .
> Say this file contains 10 records , i. e 10 instances of the above
> structure.Now I would like to read the same file in kernel space by a
> kernel module by reading 1 record at a time. How can i do this ?
>
> Is there any other way to do this without using files ?  My objective
> is to read the 10 records from kernel  space one record at a time and
> not the individual bytes.

0
Binary
9/11/2006 12:03:20 AM
http://www.linuxjournal.com/article/7356

Binary wrote:

> The best way is to use Netlink, as it is socket, it can be easily
> modified to adapt if your server is not resides in kernel (such as
> another machine).
>
> ABAI
> amit wrote:
> > struct rule{
> >         int proto;
> >          char source[15];
> >        }instance;
> >
> > I have written this structure into a file in user space ,say rule.txt .
> > Say this file contains 10 records , i. e 10 instances of the above
> > structure.Now I would like to read the same file in kernel space by a
> > kernel module by reading 1 record at a time. How can i do this ?
> >
> > Is there any other way to do this without using files ?  My objective
> > is to read the 10 records from kernel  space one record at a time and
> > not the individual bytes.

0
miline
9/12/2006 6:01:53 AM
miline wrote:
> http://www.linuxjournal.com/article/7356

hi

One week ago, I've written a kernel module and an
usermode helper application with netlink.

The current netlink code implementation in kernel
differs from the one described in the article above.

As a result of this, use netfilter and iptables
code as a reference to find out how to use netlink.


hth

Marco
0
Marco
9/12/2006 9:27:10 PM
Reply: