Package syswrap wraps syscalls (just mmap right now) in order to impose a global in-process limit on the maximum number of active mmaps.
CloseFile decrements the global count of open files and closes the file.
Mmap increments the global map count, and then calls syscall.Mmap. It decrements the map count and returns an error if the count was over the limit. If syscall.Mmap returns an error it also decrements the count.
Munmap calls sycall.Munmap, and then decrements the global map count if there was no error.
OpenFile passes the arguments along to os.OpenFile while incrementing a counter. If the counter is above the maximum, it returns mustClose true to signal the calling function that it should not keep the file open indefinitely. Files opened with this function should be closed by syswrap.CloseFile.