Hi
I have implemented a pseudo char driver/kernel module and implemented the mmap operation for learning. When user-space program calls mmap, the kernel module maps a single page of memory allocated using get_zeroed_page.
From user space, I can read/write to the page. I also implemented read operation in my module. Now read method actually reads and returns the content of the same page that I mapped to user-space from mmap (the address is stored in the module structure). The problem is read function does not seem to see the changes made in user-space. It always gets the old value. For example if in userspace program I do,
ptr = mmap (...) /* ptr is the mmapped address */
/* modify the content of the page */
for (i = 0; i < PAGE_SIZE; i++)
*ptr++ = 1;
fd = open("/dev/node", O_RDWR); /* open the device node */
read(fd, buf, PAGE_SIZE); /* read from buf */
Inside the implementation of read system call, I print the contents of tha page in log using printk. But I don't see all 1s.
Its just old content, zero filled page.
Aren't they both accessing the same page? What am I doing wrong?
Thanks,
Meraj
Catch up on fall's hot new shows on Yahoo! TV. Watch previews, get listings, and more!