All of lore.kernel.org
 help / color / mirror / Atom feed
* Simple Misc Driver - Problem with string copy to user
@ 2014-05-27 12:48 Lucas Tanure
  2014-05-27 12:59 ` Bjørn Mork
  2014-05-28  0:27 ` Le Tan
  0 siblings, 2 replies; 7+ messages in thread
From: Lucas Tanure @ 2014-05-27 12:48 UTC (permalink / raw)
  To: kernelnewbies

Hi!

Goal, when the user do :
# head -1 /dev/miscdrv

The driver prints:  Hello World!

Steps:
# Make
# insmod misc.ko
# head -1 /dev/miscdrv

Why my driver doesn't work ?

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


--
Lucas Tanure
Brazil
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20140527/87c40ed5/attachment-0001.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Makefile
Type: application/octet-stream
Size: 599 bytes
Desc: not available
Url : http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20140527/87c40ed5/attachment-0001.obj 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: misc.c
Type: text/x-csrc
Size: 1288 bytes
Desc: not available
Url : http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20140527/87c40ed5/attachment-0001.bin 

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2014-05-28  0:27 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-27 12:48 Simple Misc Driver - Problem with string copy to user Lucas Tanure
2014-05-27 12:59 ` Bjørn Mork
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

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.