Create functions for open_ro, open_rw, open_wo and error handling