473,549 Members | 2,247 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

problem with mmap

On linux, I don't understand why:

f = open ('/dev/eos', 'rw')
m = mmap.mmap(f.fil eno(), 1000000, prot=mmap.PROT_ READ|mmap.PROT_ WRITE,
flags=mmap.MAP_ SHARED)

gives 'permission denied', but this c++ code works:

#include <sys/mman.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <iostream>

int main() {
int fd = open ("/dev/eos", O_RDWR);
void* m = mmap (NULL, 1000000, PROT_READ|PROT_ WRITE, MAP_SHARED, fd, 0);
std::cout << m << '\n';
}
Jun 27 '08 #1
2 4620
On Apr 25, 9:37 am, Neal Becker <ndbeck...@gmai l.comwrote:
On linux, I don't understand why:

f = open ('/dev/eos', 'rw')
m = mmap.mmap(f.fil eno(), 1000000, prot=mmap.PROT_ READ|mmap.PROT_ WRITE,
flags=mmap.MAP_ SHARED)

gives 'permission denied',
Try

f = open('/dev/eos', 'r+')
Carl Banks
Jun 27 '08 #2
On Apr 25, 4:43*pm, Carl Banks <pavlovevide... @gmail.comwrote :
On Apr 25, 9:37 am, Neal Becker <ndbeck...@gmai l.comwrote:
On linux, I don't understand why:
f = open ('/dev/eos', 'rw')
m = mmap.mmap(f.fil eno(), 1000000, prot=mmap.PROT_ READ|mmap.PROT_ WRITE,
flags=mmap.MAP_ SHARED)
gives 'permission denied',

Try

f = open('/dev/eos', 'r+')

Carl Banks
The equivalent code in python should be:

import os, mmap
f = os.open('/dev/eos', os.O_RDWR)
m = mmap.mmap(f, 1000000, prot=mmap.PROT_ READ|mmap.PROT_ WRITE,
flags=mmap.MAP_ SHARED)

That should work like the C++ code.
Jun 27 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
4418
by: Claudio Grondi | last post by:
Background information: --------------------------------- in order to monitor mainboard sensory data as fan speeds, temperatures, applications like SpeedFan http://www.almico.com/speedfan.php or MBM http://mbm.livewiredev.com/ can be used. Both of the mentioned apps expose data got from the hardware in a shared memory area.
4
3521
by: Hao Xu | last post by:
Hi everyone! I found that if you want to write to the memory got by mmap(), you have to get the file descriptor for mmap() in O_RDWR mode. If you got the file descriptor in O_WRONLY mode, then writing to the memory got by mmap() will lead to segmentation fault. Anyone knows why? Is this a rule or a bug? What if I just want to write to...
4
3692
by: Fabiano Sidler | last post by:
Hi folks! I created an mmap object like so: --- snip --- from mmap import mmap,MAP_ANONYMOUS,MAP_PRIVATE fl = file('/dev/zero','rw') mm = mmap(fl.fileno(), 1, MAP_PRIVATE|MAP_ANONYMOUS) --- snap --- Now, when I try to resize mm to 10 byte
26
9285
by: myeates | last post by:
Hi Anyone ever done this? It looks like Python2.4 won't take a length arg Mathew
1
5456
by: James T. Dennis | last post by:
I've been thinking about the Python mmap module quite a bit during the last couple of days. Sadly most of it has just been thinking ... and reading pages from Google searches ... and very little of it as been coding. Mostly it's just academic curiosity (I might be teaching an "overview of programming" class in a few months, and I'd use...
1
1667
by: magnus.lycka | last post by:
Does anyone recognize this little Python crasher? I'll file a bug report unless someone notices it as an already documented bug. I found some open mmap bugs, but it wasn't obvious to me that this problem was one of those... Python 2.5.2 (r252:60911, Apr 21 2008, 11:12:42) on linux2 Type "help", "copyright", "credits" or "license" for...
0
2434
by: Akira Kitada | last post by:
Hi list, I was trying to build Python 2.6 on FreeBSD 4.11 and found it failed to build some of the modules. """ Failed to find the necessary bits to build these modules: _bsddb _sqlite3 _tkinter gdbm linuxaudiodev spwd sunaudiodev
0
1928
by: Akira Kitada | last post by:
Hi Marc-Andre, Thanks for the suggestion. I opened a ticket for this issue: http://bugs.python.org/issue4204 Now I understand the state of the multiprocessing module, but it's too bad to see math, mmap and readline modules, that worked fine before, cannot be built anymore.
0
1801
by: M.-A. Lemburg | last post by:
On 2008-10-25 20:19, Akira Kitada wrote: Thanks. The errors you are getting appear to be related to either some missing header files or a missing symbol definition to enable these - looking at the ticket, you seem to have resolved all this already :-)
0
7472
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7743
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7986
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
6074
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5114
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3518
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1965
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1083
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
786
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.