code: def _Open(self, path_spec, mode='rb'):
      
      if not path_spec.HasParent():
        raise errors.PathSpecError(
            'Unsupported path specification without parent.')
  
      if path_spec.parent.type_indicator != (
          definitions.TYPE_INDICATOR_APFS_CONTAINER):
        raise errors.PathSpecError(
            'Unsupported path specification not type APFS container.')
  
      apfs_container_file_system = resolver.Resolver.OpenFileSystem(
          path_spec.parent, resolver_context=self._resolver_context)
  
      fsapfs_volume = apfs_container_file_system.GetAPFSVolumeByPathSpec(
          path_spec.parent)
      if not fsapfs_volume:
        raise IOError('Unable to retrieve APFS volume')
  
      try:
        is_locked = not apfs_helper.APFSUnlockVolume(
            fsapfs_volume, path_spec.parent, resolver.Resolver.key_chain)
      except IOError as exception:
        raise IOError('Unable to unlock APFS volume with error: {0!s}'.format(
            exception))
  
      if is_locked:
        raise IOError('Unable to unlock APFS volume.')
  
      self._fsapfs_volume = fsapfs_volume
docs: Opens the file system defined by path specification.
  
      Args:
        path_spec (PathSpec): path specification.
        mode (Optional[str]): file access mode.
  
      Raises:
        AccessError: if the access to open the file was denied.
        IOError: if the APFS volume could not be retrieved or unlocked.
        OSError: if the APFS volume could not be retrieved or unlocked.
        PathSpecError: if the path specification is incorrect.
        ValueError: if the path specification is invalid.