Reputation: 31
i,
I have posted query previously and i am repeating same I want to modify igmpv3 (Linux) which is inbuilt in kernel2.6.-- such that it reads a value from a file and appropriately decides reserved(res 1) value inside the igmpv3 paket which is sent by a host.
I want to add more to above question by saying that this is more a generic question of changing variable of kernel space from user space.
Thanks in advance for your help.
Regards,
Bhavin
Upvotes: 0
Views: 3855
Reputation: 3580
From the perspective of a user land program, you should think of the driver as a "black box" with well defined interfaces instead of code with variables you can change. Using this mental model, there are four ways (i.e. interfaces) to communicate control information to the driver that you should consider:
sysfs
.proc
the process information pseudo-file system. proc
creates files in the /proc
directory which user land programs can read and sometimes write. In the past, this interface was appropriated to also communicate with drivers. Although proc
looks similarly to sysfs
, newer drivers (Linux 2.6) should use sysfs
instead as the intent of the proc
is to report on the status of processes.sysfs
is a pseudo-file system used to export information about drivers and devices. See the documentation in the kernel (Documentation/filesystems/sysfs.txt) for more details and code samples. For your particular case, pay attention to the "store" method.Depending on when you need to communicate with the driver (i.e. initialization or run time), you should add either a new command line option or a new sysfs
entry to change how the driver treats the value of reserved fields in the packet.
With regard to filp_open
, the function's comment is
/**
* This is the helper to open a file from kernelspace if you really
* have to. But in generally you should not do this, so please move
* along, nothing to see here..
*/
meaning there are better ways than this to do what you want. Also see this SO question for more information on why drivers generally should not open files.
Upvotes: 2
Reputation: 799230
You normally can't. Only structures exposed in /proc
and /sys
or via a module parameter can be modified from userspace.
Upvotes: 1