I tried to pass "string" parameter from user to kernel and the driver
never get the parameter correctly.
I have read following link as a reference:
http://tldp.org/LDP/lkmpg/2.6/html/x892.html
Then I modify get_user() with copy_from_user() as follow:
char *tmp = kmalloc(sizeof(char), GFP_KERNEL);
if (copy_from_user(tmp, (unsigned long *) param), sizeof (tmp)) {
return -EFAULT;
}
It always failed to copy user data. Did I miss anything?
In addition, I also tried it on embedded system to pass int and struct
data types with success but passing string always failed (I use 2.6.28
kernel on MIPS 4KSd family). What is the constraint on passing
parameter from user to kernel especially for "string" data type? Is it
a must to pass it via write() file operations?
I appreciate any comments or suggestions, Thanks in advance.
Regards,
DWI
--
"A mathematician is a device for turning coffee into theorems." - Paul Erdos
Contacts:
+62 857 8038 8298
+62 813 9876 6576
Skype: dwi.sasongko
GTalk: ruckuus
Thanks Abhinav and Danke. I found the issue:
Both of you are right, I wrongly allocate the memory. I never try to
pass any string before (so pity) ... I am trapped in the equality of
sizeof(int) and sizeof(*int). Different for pointer to char, the
sizeof() must not be used, instead using length of string as
parameter.
Regards,
DWI
> --
> unsubscribe: android-kerne...@googlegroups.com
> website: http://groups.google.com/group/android-kernel