SEEK_DATA/SEEK_HOLE support

This is an updated version of pull request #1516 that has been heavily modified. See the commit messages for individual details.