in reply to permission error

Yes it is obvious if you read the documentation for readdir.