python - Why is mmap returning a size of zero? -
i'm working on beaglebone (running angstrom linux) , trying use python's mmap
module gain read , write access /dev/mem
file.
however, reason, code below prints value of zero. i'm new mmap , i'm not sure if there obvious missing.
from mmap import mmap mmap_offset=0x44c00000 mmap_size=0x48ffffff-mmap_offset open("/dev/mem", "r+b") f: testmap=mmap(f.fileno(),mmap_size,offset=mmap_offset) print testmap.size() print testmap[0]
returns:
0 8
because device inodes /dev/mem
report apparent size of 0 when queried stat()
. how special device nodes implemented, it's not useful ask device node how large is. (consider /dev/zero
, /dev/kbd
, /dev/urandom
, , device node used communication , not data storage, such device nodes representing photo scanners or input devices.)
you should still able retrieve data mmap handle.
Comments
Post a Comment