Implement msync().

Resolves #851.