* char driver error
@ 2011-05-09 11:26 Aravind Vijayan
2011-05-09 11:33 ` Manohar Vanga
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Aravind Vijayan @ 2011-05-09 11:26 UTC (permalink / raw)
To: kernelnewbies
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
^ permalink raw reply [flat|nested] 6+ messages in thread* char driver error
2011-05-09 11:26 char driver error Aravind Vijayan
@ 2011-05-09 11:33 ` Manohar Vanga
[not found] ` <BANLkTimiQg3WmVRC1rOVK0+S_W095r_3Jg@mail.gmail.com>
2011-05-09 11:35 ` Daniel Baluta
2011-05-09 12:06 ` Vikash Kumar
2 siblings, 1 reply; 6+ messages in thread
From: Manohar Vanga @ 2011-05-09 11:33 UTC (permalink / raw)
To: kernelnewbies
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 at kernelnewbies.org
> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>
--
/manohar
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20110509/d3ea8807/attachment.html
^ permalink raw reply [flat|nested] 6+ messages in thread* char driver error
2011-05-09 11:26 char driver error Aravind Vijayan
2011-05-09 11:33 ` Manohar Vanga
@ 2011-05-09 11:35 ` Daniel Baluta
[not found] ` <BANLkTimAH6msz3YAt99RWPF=hOqWk6LkfQ@mail.gmail.com>
2011-05-09 12:06 ` Vikash Kumar
2 siblings, 1 reply; 6+ messages in thread
From: Daniel Baluta @ 2011-05-09 11:35 UTC (permalink / raw)
To: kernelnewbies
> 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.
^ permalink raw reply [flat|nested] 6+ messages in thread* char driver error
2011-05-09 11:26 char driver error Aravind Vijayan
2011-05-09 11:33 ` Manohar Vanga
2011-05-09 11:35 ` Daniel Baluta
@ 2011-05-09 12:06 ` Vikash Kumar
2 siblings, 0 replies; 6+ messages in thread
From: Vikash Kumar @ 2011-05-09 12:06 UTC (permalink / raw)
To: kernelnewbies
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 at kernelnewbies.org
> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20110509/bb14720f/attachment.html
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2011-05-09 12:08 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-05-09 11:26 char driver error Aravind Vijayan
2011-05-09 11:33 ` Manohar Vanga
[not found] ` <BANLkTimiQg3WmVRC1rOVK0+S_W095r_3Jg@mail.gmail.com>
2011-05-09 12:04 ` Manohar Vanga
2011-05-09 11:35 ` Daniel Baluta
[not found] ` <BANLkTimAH6msz3YAt99RWPF=hOqWk6LkfQ@mail.gmail.com>
2011-05-09 12:08 ` Daniel Baluta
2011-05-09 12:06 ` Vikash Kumar
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).