Revert "remove unnecessary stat()"

This reverts commit 44e7fd4c00242e8b60108fcedd14f95f2f5b80d8.