Find the answer to your Linux question:
Results 1 to 2 of 2
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    send message from kernel to user application


    Sorry, my question was not clear. Is it possbile to call msgsnd() from kernel space to user space?

    Thank you.

    Kind Regards.

  2. #2
    copy_from_user/copy_to_user may meet your need.

    But I myself am confusing about these functions. I hope someone give me some explanation.

    Here is prototype of the function:

    unsigned long copy_to_user (void __user * to, const void * from, unsigned long n);

    I see that function appears in kernel driver's file operations like the following:

    char data; /*kernel driver global variabe*/
    ssize_t device_read (struct file *filp, char *buffer, size_t length, loff_t *ppos)
        copy_to_user(buffer,&data, 1);
        return 1;
    In this case the to pointer transfered into the function copy_to_user is buffer. At this point I know that when calling
    read(some_file_hande, user_space_buffer)
    from userspace, user_space_buffer will be buffer in the file operation read of kernel driver. I don't know how this user_space_buffer in userspace is transfered to the file operation read in kernel driver. Just think it's some kernel implementation. But my wonder is, if I want to get a pointer of userspace address from within kernel module in general case (not in file operations of a driver), how can I do it?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts