LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices


Reply
  Search this Thread
Old 08-07-2011, 02:14 PM   #1
dasalam
LQ Newbie
 
Registered: Aug 2011
Posts: 2

Rep: Reputation: Disabled
Mmap kernel <-> userspace


Hello, all. I have kernel module that using mmap to communicte with usepscae program. Full code of this module paste.org.ru/?ii68m5. Compiliting ok, but when i try to read data drom userspace program(full code of userspace program paste.org.ru/?drk1vp) i get error "invalid address"
Code:
...
struct page *mmap_nopage(struct vm_area_struct *vma, unsigned long address, int *type)
{
    struct page *page;
    struct mmap_info *info;
    /* is the address valid? */
    if (address > vma->vm_end) {
        printk("invalid address\n");
        return NULL;
    }
Please, help me to fix this mistake. Or if you have working mmap please sent it to me. Thank you
 
Old 08-08-2011, 02:48 PM   #2
nini09
Senior Member
 
Registered: Apr 2009
Posts: 1,850

Rep: Reputation: 161Reputation: 161
In the book, http://lwn.net/Kernel/LDD3/, it has good example of mmap.
 
Old 08-08-2011, 02:57 PM   #3
dasalam
LQ Newbie
 
Registered: Aug 2011
Posts: 2

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by nini09 View Post
In the book, http://lwn.net/Kernel/LDD3/, it has good example of mmap.
Thanks, i tryed this example yesterday. And replace my func nopage with nopage function from LDD 3, but it didn't work too. I can't understand how to share information with mmap from kernel to user space. Can you explain me this point?

PS. I wrote working module using chrdev. Module code paste.org.ru/?d6jt5k. User space code paste.org.ru/?vtb1ki (/dev/simple char device created with "mknod /dev/simple c 241 0"). I understand how to read and write info from userspace, but i dont khow how do it from kernel space. Can anybody explain me?

Last edited by dasalam; 08-09-2011 at 11:30 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Userspace Executable are kernel independent? Harini1111 Linux - Kernel 2 12-05-2008 10:26 AM
Using kernel functions and macros in userspace karimasif Linux - General 1 01-16-2008 11:34 PM
Passing IP options data to kernel from userspace kaushik1 Programming 2 12-26-2007 11:38 PM
a question about kernel copy userspace data linwenyuan Programming 0 03-28-2007 09:55 AM
Jiffies a kernel only entity, or is it allowed in userspace also? pat_and_cami Programming 0 03-10-2006 12:36 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 11:39 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration