From: bjorn@mork.no (Bjørn Mork)
To: kernelnewbies@lists.kernelnewbies.org
Subject: Simple Misc Driver - Problem with string copy to user
Date: Tue, 27 May 2014 14:59:56 +0200 [thread overview]
Message-ID: <87ppizgywj.fsf@nemi.mork.no> (raw)
In-Reply-To: <CAJyon0uo=TH_rS-zx_nr2G-nJDLAiWGuc=MDc1aVo7y96grwng@mail.gmail.com> (Lucas Tanure's message of "Tue, 27 May 2014 09:48:43 -0300")
Lucas Tanure <tanure@linux.com> writes:
>> What is worg with my read operation?
>
> static ssize_t
> misc_drv_read(struct file *filp, char __user * buf, size_t count, loff_t *
> offp){
> int nbytes;
> char * string = "hello World";
> nbytes = copy_to_user(buf, string, 12);
> return nbytes;
> }
copy_to_user returns the number of bytes which could *not* be copied.
So it will return 0 on success, making your read return 0.
Bj?rn
next prev parent reply other threads:[~2014-05-27 12:59 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-27 12:48 Simple Misc Driver - Problem with string copy to user Lucas Tanure
2014-05-27 12:59 ` Bjørn Mork [this message]
2014-05-27 13:03 ` Lucas Tanure
2014-05-27 13:05 ` Bjørn Mork
2014-05-27 13:09 ` Lucas Tanure
2014-05-27 13:33 ` Bernd Petrovitsch
2014-05-28 0:27 ` Le Tan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87ppizgywj.fsf@nemi.mork.no \
--to=bjorn@mork.no \
--cc=kernelnewbies@lists.kernelnewbies.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.