Follow up to #47324. Instead of calling `stat` and then `open`, do `open` and then `fstat`. In my tests on macOS this is significantly faster.