Backport: GHC#8741 handle access(2) EROFS

Information from GHC#8741: `System.Directory.getPermissions` fails on
read-only filesystem:
https://ghc.haskell.org/trac/ghc/ticket/8741

```
Prelude> System.Directory.getPermissions "/usr/bin/ld"
*** Exception: /usr/bin/ld: fileAccess: permission denied (Read-only file system)
```

That seems wrong.

An access(*, W_OK) syscall by design should return EROFS on a read-only file
system by specification. This breaks Cabal on SmartOS since /usr is read-only
by design and Cabal calls getPermissions "/usr/bin/ld".

Upstream patch for package unix:
https://ghc.haskell.org/trac/ghc/changeset/444750d2e5c6b843b937cbe876ce248e76a2a245/unix)