Conceptually, mremap() really only extends/shrinks the memory mapping, so
the new pages will be an extension of whatever the old mmap was. In most
cases (at least for the malloc case) this will be a anonymous mapping,
but it's by no means an error to extend any mapping you have created.
Extending a file mapping could potentially be useful if you want to track
a file when it grows, for example. You'd just do something like
addr = mmap(... st.st_size ...)
for the initial mapping, and then when the process notices that the file
has grown (or shrunk), it does a
mremap(addr, old_size, st.st_size)
to be able to read the new pages. A very logical interface, in fact.
Linus