On Fri, Sep 10, 2010 at 05:51:41PM +0200, fabio de francesco wrote:
>
> static ssize_t
> mycdrv_read (struct file *file, char __user * buf, size_t lbuf, loff_t * ppos)
> {
>     int nbytes, maxbytes, bytes_to_do;
>     maxbytes = KBUF_SIZE - *ppos;
>     bytes_to_do = lbuf <= maxbytes ? lbuf : maxbytes;
>     nbytes = lbuf - copy_to_user (buf, kbuf + *ppos, bytes_to_do);
>     *ppos += nbytes;
>     printk (KERN_INFO "\n READING function, nbytes=%d, pos=%d\n", nbytes,
>             (int)*ppos);
>     return nbytes;
> }

I'm not going to flat out answer your query, but help you work towards
the solution yourself.

Think about the termination case.  In order to terminate, you'll need to
return 0 to signal an end of file to the user-mode read.

In what case could your code return 0?

-- 
                                          -joshc

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to [email protected]
Please read the FAQ at http://kernelnewbies.org/FAQ

Reply via email to