[PLUG] Problem in proc write
shakthimaan at gmail.com
Thu Jun 25 11:12:47 IST 2009
--- On Wed, Jun 24, 2009 at 11:39 AM, paras<beparas at gmail.com> wrote:
| int ret, val;
| printk(KERN_INFO "Entering Function %s \n", __FUNCTION__);
| ret = copy_from_user(&val, buffer, length);
'val' can be used as 'char *' buffer.
| / # echo 1 > /proc/test/mychrdev1
| Entering Function mychrdev_proc_write
| val = 822738944
1. echo by default adds a \n in the output. So, if you printk the
length value in your code, you will get length as '2'. To suppress the
newline and just get '1' in the above, you should use:
echo -n 1 > /proc/test/mychrdev1
2. You should initialize your local variables, val, and ret to zero.
If you do printk %d, %x on val for the above, it will print '49' and
'31' respectively. They are the decimal and hexadecimal equivalents of
the character '1' that has been passed.
Also refer, 'Access the Linux kernel using the /proc filesystem':
Not sure why you want to use /proc, as /sysfs is used in 2.6.
More information about the Plug-mail