Opens the FVDE volume using the path specification.

  Args:
    fvde_volume (pyfvde.volume): FVDE volume.
    path_spec (PathSpec): path specification.
    file_object (FileIO): file-like object.
    key_chain (KeyChain): key chain.
975403
def FVDEVolumeOpen(fvde_volume, path_spec, file_object, key_chain):
  
  encrypted_root_plist = key_chain.GetCredential(
      path_spec, 'encrypted_root_plist')
  if encrypted_root_plist:
    fvde_volume.read_encrypted_root_plist(encrypted_root_plist)

  password = key_chain.GetCredential(path_spec, 'password')
  if password:
    fvde_volume.set_password(password)

  recovery_password = key_chain.GetCredential(path_spec, 'recovery_password')
  if recovery_password:
    fvde_volume.set_recovery_password(recovery_password)

  fvde_volume.open_file_object(file_object)
67611
def detach_volume(self, volume):
        
        if hasattr(volume, "id"):
            volume_id = volume.id
        else:
            volume_id = volume
        return self.ec2.detach_volume(volume_id=volume_id, instance_id=self.instance_id)
589016
def GetFileEntryByPathSpec(self, path_spec):
    
    # Opening a file by MFT entry is faster than opening a file by location.
    # However we need the index of the corresponding $FILE_NAME MFT attribute.
    fsntfs_file_entry = None
    location = getattr(path_spec, 'location', None)
    mft_attribute = getattr(path_spec, 'mft_attribute', None)
    mft_entry = getattr(path_spec, 'mft_entry', None)

    if (location == self.LOCATION_ROOT or
        mft_entry == self.MFT_ENTRY_ROOT_DIRECTORY):
      fsntfs_file_entry = self._fsntfs_volume.get_root_directory()
      return ntfs_file_entry.NTFSFileEntry(
          self._resolver_context, self, path_spec,
          fsntfs_file_entry=fsntfs_file_entry, is_root=True)

    try:
      if mft_attribute is not None and mft_entry is not None:
        fsntfs_file_entry = self._fsntfs_volume.get_file_entry(mft_entry)
      elif location is not None:
        fsntfs_file_entry = self._fsntfs_volume.get_file_entry_by_path(location)

    except IOError as exception:
      raise errors.BackEndError(exception)

    if fsntfs_file_entry is None:
      return None

    return ntfs_file_entry.NTFSFileEntry(
        self._resolver_context, self, path_spec,
        fsntfs_file_entry=fsntfs_file_entry)
1345730
def subvolume_show(path):
    '''
    

    '''
    cmd = ['btrfs', 'subvolume', 'show', path]

    res = __salt__['cmd.run_all'](cmd)
    salt.utils.fsutils._verify_run(res)

    result = {}
    table = {}
    # The real name is the first line, later there is a table of
    # values separated with colon.
    stdout = res['stdout'].splitlines()
    key = stdout.pop(0)
    result[key.strip()] = table

    for line in stdout:
        key, value = line.split(':', 1)
        table[key.lower().strip()] = value.strip()
    return result
164317
def open_asset_path(self, *args, **kwargs):
        
        f = self.asset_path_le.text()
        d = os.path.dirname(f)
        osinter = get_interface()
        osinter.open_path(d)
926534
def attach_volume(self, volume, device="/dev/sdp"):
        
        if hasattr(volume, "id"):
            volume_id = volume.id
        else:
            volume_id = volume
        return self.ec2.attach_volume(volume_id=volume_id, instance_id=self.instance_id, device=device)
103088
def new(self):
        # type: () -> None
        '''
        
        '''
        if self._initialized:
            raise pycdlibexception.PyCdlibInternalError('UDF Anchor Volume Structure already initialized')

        self.desc_tag = UDFTag()
        self.desc_tag.new(2)  # FIXME: we should let the user set serial_number
        self.main_vd_length = 32768
        self.main_vd_extent = 0  # This will get set later.
        self.reserve_vd_length = 32768
        self.reserve_vd_extent = 0  # This will get set later.

        self._initialized = True
991499
def RegistryKeyFromClient(args):
  
  for path in _GetExpandedPaths(args):
    pathspec = rdf_paths.PathSpec(
        path=path, pathtype=rdf_paths.PathSpec.PathType.REGISTRY)
    with vfs.VFSOpen(pathspec) as file_obj:
      yield file_obj.Stat()
294940
def create_osd_keyring(conn, cluster, key):
    
    logger = conn.logger
    path = '/var/lib/ceph/bootstrap-osd/{cluster}.keyring'.format(
        cluster=cluster,
    )
    if not conn.remote_module.path_exists(path):
        logger.warning('osd keyring does not exist yet, creating one')
        conn.remote_module.write_keyring(path, key)
192154
def _parse_volumes(volume_values: dict) -> str:
        
        for v_values in volume_values:
            for v_key, v_value in v_values.items():
                if v_key == 'source':
                    if v_value == '.':
                        source = os.path.dirname(
                            os.path.abspath(__file__))
                    else:
                        source = v_value
                if v_key == 'target':
                    target = v_value
            volume_spec = [source + ':' + target]
            return volume_spec
79103
def open_vos_or_local(path, mode="rb"):
    
    filename = os.path.basename(path)
    if os.access(filename, os.F_OK):
        return open(filename, mode)
    if path.startswith("vos:"):
        primary_mode = mode[0]
        if primary_mode == "r":
            vofile_mode = os.O_RDONLY
        elif primary_mode == "w":
            vofile_mode = os.O_WRONLY
        elif primary_mode == "a":
            vofile_mode = os.O_APPEND
        else:
            raise ValueError("Can't open with mode %s" % mode)

        return vofile(path, mode=vofile_mode)
    else:
        return open(path, mode)
758910
def open(self, path, mode='r', *args, **kwargs):
        """"""
        return open(os.path.join(os.path.dirname(self.path), path),
                    mode=mode, *args, **kwargs)
183428
def open(self, external_dir=None):
        
        if self.kind == 'data':
            with io.BytesIO(self._data.data) as f:
                yield f
        elif self.kind == 'external':
            filepath = self._data.linked_file[b'fullPath'].value
            filepath = filepath.replace('\x00', '').replace('file://', '')
            if not os.path.exists(filepath):
                filepath = self._data.linked_file[b'relPath'].value
                filepath = filepath.replace('\x00', '')
                if external_dir is not None:
                    filepath = os.path.join(external_dir, filepath)
            if not os.path.exists(filepath):
                raise FileNotFoundError(filepath)
            with open(filepath, 'rb') as f:
                yield f
        else:
            raise NotImplementedError('alias is not supported.')
799340
def APFSContainerPathSpecGetVolumeIndex(path_spec):
  
  volume_index = getattr(path_spec, 'volume_index', None)
  if volume_index is not None:
    return volume_index

  location = getattr(path_spec, 'location', None)
  if location is None or not location.startswith('/apfs'):
    return None

  try:
    volume_index = int(location[5:], 10) - 1
  except (TypeError, ValueError):
    volume_index = None

  if volume_index is None or volume_index < 0 or volume_index > 99:
    volume_index = None

  return volume_index
745817
def new(self):
        # type: () -> None
        '''
        
        '''
        if self._initialized:
            raise pycdlibexception.PyCdlibInternalError('UDF Partition Volume Descriptor already initialized')

        self.desc_tag = UDFTag()
        self.desc_tag.new(5)  # FIXME: we should let the user set serial_number

        self.vol_desc_seqnum = 2
        self.part_flags = 1  # FIXME: how should we set this?
        self.part_num = 0  # FIXME: how should we set this?

        self.part_contents = UDFEntityID()
        self.part_contents.new(2, b'+NSR02')

        self.part_contents_use = UDFPartitionHeaderDescriptor()
        self.part_contents_use.new()

        self.access_type = 1
        self.part_start_location = 0  # This will get set later
        self.part_length = 3  # This will get set later

        self.impl_ident = UDFEntityID()
        self.impl_ident.new(0, b'*pycdlib')

        self.implementation_use = b'\x00' * 128  # FIXME: we should let the user set this

        self._initialized = True
541954
def _OpenFileObject(self, path_spec):
    
    if not path_spec.HasParent():
      raise errors.PathSpecError(
          'Unsupported path specification without parent.')

    file_object = resolver.Resolver.OpenFileObject(
        path_spec.parent, resolver_context=self._resolver_context)
    qcow_file = pyqcow.file()
    qcow_file.open_file_object(file_object)
    return qcow_file
68612
def assure_volume(fnc):
    
    @wraps(fnc)
    def _wrapped(self, volume, *args, **kwargs):
        if not isinstance(volume, CloudBlockStorageVolume):
            # Must be the ID
            volume = self._manager.get(volume)
        return fnc(self, volume, *args, **kwargs)
    return _wrapped