From mboxrd@z Thu Jan 1 00:00:00 1970 From: bjorn@mork.no (=?utf-8?Q?Bj=C3=B8rn_Mork?=) Date: Tue, 27 May 2014 14:59:56 +0200 Subject: Simple Misc Driver - Problem with string copy to user In-Reply-To: (Lucas Tanure's message of "Tue, 27 May 2014 09:48:43 -0300") References: Message-ID: <87ppizgywj.fsf@nemi.mork.no> To: kernelnewbies@lists.kernelnewbies.org List-Id: kernelnewbies.lists.kernelnewbies.org 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 returns the number of bytes which could *not* be copied. So it will return 0 on success, making your read return 0. Bj?rn