RE: char driver module prob.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



 
> static ssize_t Device_read(struct file *filp,char *buf,size_t
> count,loff_t *offset)
> {
>         if (*offset >= sizeof(msg) )
>         {
>                 return 0;
>         }
> 
>         count = sizeof(msg);
> 
>         if(copy_to_user(buf, msg, count))
>                 return -EFAULT;
> 
>         *offset += count;
>         return count;
> }
> 


Well.. i had similar program some time back, which worked fine.
I guess the problem is with the --first call-- to the read function where you are assuming that the value will be >= message size. Try printing out there itself what is the value of "offset" is!


--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/



[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux