Sorry,
it was my mistake !
seg fault was by reading of data. To do this should PROT_READ|PROT_WRITE be
setted.
Now it works!

Alexej


---------- Forwarded message ----------
From: Alexej Sokolov <bsd.qu...@googlemail.com>
Date: 2009/3/10
Subject: write protection by mmap of /dev/mem doesn't work
To: freebsd-hackers@freebsd.org


hello,
How can I mmap some memory regions with PROT_WRITE protection flag ?
What i do:
 /* Open mem device */
        if ((devmem_fd = open("/dev/mem", O_RDWR)) == -1){
                perror("/dev/mem");
                exit (1);
        }

then if I try to mmap some memory region with PROT_READ it goes Ok. But by
PROT_WRITE it doesn't work:
sp =    mmap (  0,
                       MCLBYTES,       /* Size of remapped buffer = size of
mbuf cluster */
                       PROT_WRITE,
                       MAP_SHARED,
                       devmem_fd,
                       phys_addr       /* Physical addres of packet buffer
from descriptor */
                     );
I get by PROT_WRITE " segmentation fault"
What is the problem here ?
And question again:
How can I do it possible to remapp the kernel memory region to user space
process through /dev/mem and give to this user process write permissions to
remmaped space ?

Thanx
_______________________________________________
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "freebsd-hackers-unsubscr...@freebsd.org"

Reply via email to