Use open+fstat instead of stat+open.