[#2338] Make sure mmap can be used for writing.

1. In Win32, use explicit maximum size; in order to avoid having to stat
   and, more importantly, to be able to extend mapped file when writing,
   use the end of the explicitly requested buffer.

2. Expose the page size, to be able to write in manageable chunks.

3. Add convenience structures for writing to mapped views.

4. Finally, add p_ftruncate since mapped file is longer than necessary
   and will have to be resized.
[#2338] Allow opening filebuf for reading as well.

Since for temporary filebuf a call to mkstemp() is used, fix its Win32
version which only opened the file for writing; normally, the function
is expected to create a file for reading and writing and apply 0600 as
the permissions. See, for instance:

http://man7.org/linux/man-pages/man3/mkstemp.3.html
[#2338] Use mmap to write to indexer packfile.

Make sure to open the packfile for reading and truncate when done.
Slightly optimize read memory caching.

Since we are now using mmap for writing, there is no longer any need to
unmap read memory just because the file has been extended, since we are
requesting MAP_SHARED in both cases.

When mapping a window, extend the length to a page size multiple; thus,
need to ensure to read only the region that has been written so far.