Why is mmap returning a size of zero?
Question: I'm working on a beaglebone (running Angstrom Linux) and trying to use
Python's `mmap` module to gain read and write access to the `/dev/mem` file.

However, for some reason, the code below prints a value of zero. I'm fairly
new to mmap and I'm not sure if there is something obvious I am missing.

    
    
    from mmap import mmap
    
    mmap_offset=0x44c00000
    mmap_size=0x48ffffff-mmap_offset
    
    with open("/dev/mem", "r+b") as f:
        testMap=mmap(f.fileno(),mmap_size,offset=mmap_offset)
    
    print testMap.size()
    print testMap[0]
    

returns:

    
    
    0
    8
    


Answer: Because device inodes like `/dev/mem` report an apparent size of 0 when
queried by [`stat()`](http://linux.die.net/man/2/stat). This is simply how
special device nodes are implemented, as it's not usually useful to ask a
device node how large it is. (Consider `/dev/zero`, `/dev/kbd`,
`/dev/urandom`, and any device node that is used for communication and not
data storage, such as device nodes representing photo scanners or input
devices.)

You should still be able to retrieve data from the mmap handle.

