RE: char driver module prob.

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

 



On Tue, 2005-03-29 at 16:18 +0530, Dhanashri Bhate wrote:
>  > 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!
> 
first time >>>>>>> offset = 0;
second time >>>>>> offset = 6; (total size of string including '\0')

so it's fine here.

-mandeep

--
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