[SOLVED] Can we perform TWO MMAP operation on same /dev file
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
if (usr_dest_ptr == MAP_FAILED){
printf("USR[UPP]DEST MMAP FAiled \n\n");
close(dev_FD);
exit(-1);
}else{
printf("USR[UPP]DEST MMAP is %X..\n",usr_dest_ptr);
}
1. I am writing 0x77 in user_src_ptr in user space & printing
user_src_ptr in user space and dest_src_ptr in KERNEL space .
I get correct data for both user and kernel space
2. I am writng 0x55 in dest_ptr in kernel space & printing dest_ptr
in kernel space and usr_dest_ptr in user space.
NOW FOR THIS CASE I GET CORRECT DATA I.E 0X55 IN KERNEL BUFFER
dest_ptR , BUT THE USER SPACE BUFFER OF DESTINATION ALWAYS
RETURNS 0X77 . i.e THE DATA WHICH I HAVE WRITTEN IN usr_src_ptr.
Can any one please let me know if we can do TWO MMAP operation on same file at different OFFSET ?????
The issue was with :-
if ((ret = remap_pfn_range(vma,vma->vm_start, (virt_to_phys((void *)src_ptr) >> PAGE_SHIFT),
size,vma->vm_page_prot)) < 0)
{
return ret;
}
Due to this ir-respective of offset , i was getting mapped to same PHYSICAL address
Mina86 ,
Actually i wanted to do an mmap of two kernel buffer of my character driver.
So on single /dev file i am doing an mmap of two buffer .
To distinguish these buffer i am using PHYSICAL address of both buffer as an OFFSET parameter from user space .
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.