Following are my observations from the code:<br><br>1) The driver is maintaining a 1 byte buffer.<br>memory_buffer <span class="sy0">=</span> kmalloc<span class="br0">(</span><span class="nu0">1</span><span class="sy0">,</span> GFP_KERNEL<span class="br0">)</span><span class="sy0">;<br>

<br></span>2) Write operation always copies the last byte of user buffer to driver buffer.<br>tmp<span class="sy0">=</span>buf<span class="sy0">+</span>count<span class="sy0">-</span><span class="nu0">1</span><span class="sy0">;</span>  <br>

copy_from_user<span class="br0">(</span>memory_buffer<span class="sy0">,</span>tmp<span class="sy0">,</span><span class="nu0">1</span><span class="br0">)</span><span class="sy0"></span><br><br>3) Read operation always returns the copied character from driver buffer on every read ignoring the count.<br>

 copy_to_user<span class="br0">(</span>buf<span class="sy0">,</span>memory_buffer<span class="sy0">,</span><span class="nu0">1</span><span class="br0">)</span><span class="sy0">;</span><br><br>So, to me it seems everything is working fine.. what&#39;s the error here ? what am I missing something?<br>

<br><br clear="all">Regards,<br>Vikash Kumar<br><br><br>
<br><br><div class="gmail_quote">On Mon, May 9, 2011 at 4:56 PM, Aravind Vijayan <span dir="ltr">&lt;<a href="mailto:aravind1123@gmail.com">aravind1123@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

Hi all,<br>
       Let me begin this post with thanx all to whom help me on<br>
previous problem.I have completed jobs such as<br>
writing,making,inserting the  module.<br>
<br>
i create a character special file using mknod in /dev directory.<br>
<br>
i try to write data to my file by&quot; echo -n &quot;abcd&quot; &gt; /dev/memory &quot;<br>
<br>
and when i try to read from that file i get  the last char was written<br>
to that file that is &quot;d&quot;<br>
<br>
here is my code:<a href="http://pastebin.com/9YsJetek" target="_blank">http://pastebin.com/9YsJetek</a><br>
<br>
_______________________________________________<br>
Kernelnewbies mailing list<br>
<a href="mailto:Kernelnewbies@kernelnewbies.org">Kernelnewbies@kernelnewbies.org</a><br>
<a href="http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies" target="_blank">http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies</a><br>
</blockquote></div><br>