Fix stat/lstat error checking in a few places.

closes #6929. Please review.
Did you address the `return err` below?