fix filestat call, give permissions