Handle O_RDONLY, O_WRONLY and O_RDWR correctly in GlibIOStore

We should pass flags instead of mode to the function
flags_to_restrict_mode().