bsd seems to mess up stat syscalls, so call directly