Fix potential LFS related issues

This patch-set supersedes the #3 PR (but needs testing on Solaris)
This needs to be guarded by an #ifdef, unix should continue to work on GHC <7.6.