Quantcast
Channel: Active questions tagged kernel - Stack Overflow
Viewing all articles
Browse latest Browse all 6402

copy_to_user not copying data

$
0
0

I have this code in c where I'm supposed to copy data from one string to another. However, it's not copying and I don't know the specific reason. Any ideas why?

asmlinkage long sys_receive_message(int mid, char* message, int maxlength){    struct list_head *i;    mutex_lock(&messageMutex);    list_for_each(i, &messageList) {            struct message_list *obj = list_entry(i, struct message_list, list);            if(obj->mid == mid){                printk("Found the message");                if(obj->length>maxlength){                    maxlength = obj->length;                    printk("Maxlength changed");                }                copy_to_user(message, obj->message, sizeof(obj->message));                //printk("%d\n",&obj->length);                list_del(i);                printk("Deleted the message");                kfree(obj);                printk("Freed the message");                mutex_unlock(&messageMutex);                return 1; // Succeeded           }    }    mutex_unlock(&messageMutex);    return 0; // Did not find mid in the list}

Viewing all articles
Browse latest Browse all 6402

Trending Articles