Hi all, Let me begin this post with thanx all to whom help me on previous problem.I have completed jobs such as writing,making,inserting the module. i create a character special file using mknod in /dev directory. i try to write data to my file by" echo -n "abcd" > /dev/memory " and when i try to read from that file i get the last char was written to that file that is "d" here is my code:http://pastebin.com/9YsJetek
This line is incorrect. You need to learn how kmalloc (or any *alloc for that matter) works because it seems like you don't realise what is happening with this statement. memory_buffer = kmalloc(1, GFP_KERNEL); On Mon, May 9, 2011 at 1:26 PM, Aravind Vijayan <aravind1123@gmail.com>wrote:
Hi all, Let me begin this post with thanx all to whom help me on previous problem.I have completed jobs such as writing,making,inserting the module.
i create a character special file using mknod in /dev directory.
i try to write data to my file by" echo -n "abcd" > /dev/memory "
and when i try to read from that file i get the last char was written to that file that is "d"
here is my code:http://pastebin.com/9YsJetek
_______________________________________________ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
-- /manohar
i create a character special file using mknod in /dev directory.
i try to write data to my file by" echo -n "abcd" > /dev/memory "
and when i try to read from that file i get the last char was written to that file that is "d"
Hello Aravind, Can you post the output for: $ strace -n "abcd" > /dev/memory $ strace cat /dev/memory a thanks, Daniel.
Following are my observations from the code: 1) The driver is maintaining a 1 byte buffer. memory_buffer = kmalloc(1, GFP_KERNEL); 2) Write operation always copies the last byte of user buffer to driver buffer. tmp=buf+count-1; copy_from_user(memory_buffer,tmp,1) 3) Read operation always returns the copied character from driver buffer on every read ignoring the count. copy_to_user(buf,memory_buffer,1); So, to me it seems everything is working fine.. what's the error here ? what am I missing something? Regards, Vikash Kumar On Mon, May 9, 2011 at 4:56 PM, Aravind Vijayan <aravind1123@gmail.com>wrote:
Hi all, Let me begin this post with thanx all to whom help me on previous problem.I have completed jobs such as writing,making,inserting the module.
i create a character special file using mknod in /dev directory.
i try to write data to my file by" echo -n "abcd" > /dev/memory "
and when i try to read from that file i get the last char was written to that file that is "d"
here is my code:http://pastebin.com/9YsJetek
_______________________________________________ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
participants (4)
-
Aravind Vijayan -
Daniel Baluta -
Manohar Vanga -
Vikash Kumar