Re: Simple Misc Driver - Problem with string copy to user

2014-05-27 Thread Le Tan
I think it is good for you to read LDD3 or google some corresponding materials at first. 2014-05-27 20:48 GMT+08:00 Lucas Tanure : > Hi! > > Goal, when the user do : > # head -1 /dev/miscdrv > > The driver prints: Hello World! > > Steps: > # Make > # insmod misc.ko > # head -1 /dev/miscdrv > > Wh

Re: Simple Misc Driver - Problem with string copy to user

2014-05-27 Thread Bernd Petrovitsch
Hi! On Die, 2014-05-27 at 10:09 -0300, Lucas Tanure wrote: > Wow, many thanks. > So the read operation should return the total number of bytes, not a > true/false int. The syscall here (done by `head`) is read() ... > I need to read more about this operations. .. and the drivers .read function

Re: Simple Misc Driver - Problem with string copy to user

2014-05-27 Thread Lucas Tanure
Wow, many thanks. So the read operation should return the total number of bytes, not a true/false int. I need to read more about this operations. Thanks -- Lucas Tanure +55 (19) 988176559 On Tue, May 27, 2014 at 10:05 AM, Bjørn Mork wrote: > Lucas Tanure writes: > > > So, My misc_drv_read r

Re: Simple Misc Driver - Problem with string copy to user

2014-05-27 Thread Bjørn Mork
Lucas Tanure writes: > So, My misc_drv_read returns 0, and it's ok. So why the command head didn't > get the string ? You told it that it got a string with length 0. And that's what it printed. Bjørn ___ Kernelnewbies mailing list Kernelnewbies@ker

Re: Simple Misc Driver - Problem with string copy to user

2014-05-27 Thread Lucas Tanure
So, My misc_drv_read returns 0, and it's ok. So why the command head didn't get the string ? -- Lucas Tanure +55 (19) 988176559 On Tue, May 27, 2014 at 9:59 AM, Bjørn Mork wrote: > Lucas Tanure writes: > > >> What is worg with my read operation? > > > > static ssize_t > > misc_drv_read(struct

Re: Simple Misc Driver - Problem with string copy to user

2014-05-27 Thread Bjørn Mork
Lucas Tanure 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 re

Simple Misc Driver - Problem with string copy to user

2014-05-27 Thread Lucas Tanure
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