Refactor _mmap_serve() and _dirlist_serve()

Use a common function that does pretty much the same thing.