driver copy_to_user

Mulyadi Santosa mulyadi.santosa at gmail.com
Fri Dec 24 13:29:43 EST 2010


Hi...:)

On Fri, Dec 24, 2010 at 13:40, Hemanth Kumar <hemwire at yahoo.co.in> wrote:
> Hi mulyadi,
>
>          Sorry for sending the mail directly,

It's ok, but just to let you know..I am just average when dealing with kernel :)

> ssize_t my_read(struct file *file,char *buf,size_t count,loff_t *pos){
>     unsigned long res;
>     void *k = (void *)&x;
>          void *l = (void *)&x+1;
>          void *j = (void *)&x+2;
>
>                     mutex_lock(&timer);
>                             res =    copy_to_user(buf,k,sizeof(short));


hm, you say "read from user space", right? Then why "copy_to_user"?
shouldn't it be "copy_from_user"?
-- 
regards,

Mulyadi Santosa
Freelance Linux trainer and consultant

blog: the-hydra.blogspot.com
training: mulyaditraining.blogspot.com



More information about the Kernelnewbies mailing list