vfs: Improve robustness of error handling

Issue #999