next up previous contents
Next: munlock: unlock a region Up: MOSS system calls Previous: mlockall: lock all memory

mmap: map a file's contents into memory


void *mmap(void *addr, size_t len, int prot, int flags, int fd, off_t offset);


This system call implements the POSIX.1b mmap function, which maps a file into the program's address space.

Currently, MOSS only supports this function on the ``magic'' file `/dev/mem'; it will fail if used on any other file. You can mmap /dev/mem in order to gain direct access to physical memory, which is not normally available to the program running under MOSS.

Note that the munmap function is not currently supported. (Actually, it is available, but it simply returns success without doing anything.)


The desired address at which to map the file. Currently MOSS always ignores this paramter.
Size in bytes of the file region to map.
Permissions to apply to the mapped memory. Currently MOSS simply ignores this parameter and always provides full permissions.
Flags describing how to map the file. Currently MOSS simply ignores this parameter and behaves as if MAP_SHARED was specified.
The file descriptor of the file to map. Currently this must be a file descriptor opened on the special file /dev/mem.
Starting offset in the file to map. For /dev/mem, this is the physical address to map from.


Returns the start address of the mapped region if successful, or (void*)-1 on error, in which case errno indicates the error.

Bryan Ford