467,222 Members | 1,447 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,222 developers. It's quick & easy.

problem with mmap

On linux, I don't understand why:

f = open ('/dev/eos', 'rw')
m = mmap.mmap(f.fileno(), 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
  • viewed: 4122
Share:
2 Replies
On Apr 25, 9:37 am, Neal Becker <ndbeck...@gmail.comwrote:
On linux, I don't understand why:

f = open ('/dev/eos', 'rw')
m = mmap.mmap(f.fileno(), 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...@gmail.comwrote:
On linux, I don't understand why:
f = open ('/dev/eos', 'rw')
m = mmap.mmap(f.fileno(), 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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Hao Xu | last post: by
4 posts views Thread by Fabiano Sidler | last post: by
26 posts views Thread by myeates@jpl.nasa.gov | last post: by
1 post views Thread by James T. Dennis | last post: by
1 post views Thread by magnus.lycka@gmail.com | last post: by
reply views Thread by Adict | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.