Return logical volume that stores the given path

		:param file_path: target path to search
		:param sudo: same as 'sudo' in :meth:`.WLogicalVolume.__init__`
		:return: WLogicalVolume or None (if file path is outside current mount points)
182629
def logical_volume(cls, file_path, sudo=False):
		
		mp = WMountPoint.mount_point(file_path)
		if mp is not None:
			name_file = '/sys/block/%s/dm/name' % mp.device_name()
			if os.path.exists(name_file):
				lv_path = '/dev/mapper/%s' % open(name_file).read().strip()
				return WLogicalVolume(lv_path, sudo=sudo)
1330465
def _relativePath(self, fullPath):
        
        if fullPath is None:
            return None

        assert fullPath.startswith("/"), fullPath

        path = os.path.relpath(fullPath, self.userPath)

        if not path.startswith("../"):
            return path
        elif self.ignoreExtraVolumes:
            return None
        else:
            return fullPath
1034476
def ismount(path):
    
    host, _, path_ = split(path, None)
    if host:
        return False
    return os.path.ismount(path_)
535472
def GetMountPoint(self, path=None):
    
    path = os.path.abspath(
        client_utils.CanonicalPathToLocalPath(path or self.path))

    while not os.path.ismount(path):
      path = os.path.dirname(path)

    return path
50477
def GetFileEntryByPathSpec(self, path_spec):
    
    tsk_vs_part, partition_index = tsk_partition.GetTSKVsPartByPathSpec(
        self._tsk_volume, path_spec)

    location = getattr(path_spec, 'location', None)

    # The virtual root file has not corresponding TSK volume system part object
    # but should have a location.
    if tsk_vs_part is None:
      if location is None or location != self.LOCATION_ROOT:
        return None

      return tsk_partition_file_entry.TSKPartitionFileEntry(
          self._resolver_context, self, path_spec, is_root=True,
          is_virtual=True)

    if location is None and partition_index is not None:
      path_spec.location = '/p{0:d}'.format(partition_index)

    return tsk_partition_file_entry.TSKPartitionFileEntry(
        self._resolver_context, self, path_spec)
270969
def GetAPFSVolumeByPathSpec(self, path_spec):
    
    volume_index = apfs_helper.APFSContainerPathSpecGetVolumeIndex(path_spec)
    if volume_index is None:
      return None

    return self._fsapfs_container.get_volume(volume_index)
710469
def FileEntryExistsByPathSpec(self, path_spec):
    
    # Opening a file by identifier is faster than opening a file by location.
    fsapfs_file_entry = None
    location = getattr(path_spec, 'location', None)
    identifier = getattr(path_spec, 'identifier', None)

    try:
      if identifier is not None:
        fsapfs_file_entry = self._fsapfs_volume.get_file_entry_by_identifier(
            identifier)
      elif location is not None:
        fsapfs_file_entry = self._fsapfs_volume.get_file_entry_by_path(location)

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

    return fsapfs_file_entry is not None
138981
def _fillVolumesAndPaths(self, paths):
        
        for (volDict, volPaths) in self._client.fillVolumesAndPaths():
            vol = Store.Volume(**volDict)
            paths[vol] = volPaths
258242
def GetRootFileEntry(self):
    
    path_spec = ntfs_path_spec.NTFSPathSpec(
        location=self.LOCATION_ROOT, mft_entry=self.MFT_ENTRY_ROOT_DIRECTORY,
        parent=self._path_spec.parent)
    return self.GetFileEntryByPathSpec(path_spec)
1242098
def _backup_file(path):
    
    backup_base = '/var/local/woven-backup'
    backup_path = ''.join([backup_base,path])
    if not exists(backup_path):
        directory = ''.join([backup_base,os.path.split(path)[0]])
        sudo('mkdir -p %s'% directory)
        sudo('cp %s %s'% (path,backup_path))
48147
def get_dir(self, path):
        
        try:
            longest = max(m for m in self.mounts if path.startswith(m))
            return self.mounts[longest]
        except ValueError:
            return None
22316
def mkpath(filepath, permissions=0o777):
   
   # Converting string of octal to integer, if string is given.
   if isinstance(permissions, str):
      permissions = sum([int(x)*8**i for i,x in enumerate(reversed(permissions))])
   # Creating directory
   if not os.path.exists(filepath):
      debug.log("Creating Directory %s (permissions: %s)"%(
         filepath, permissions))
      os.makedirs(filepath, permissions)
   else:
      debug.log("Warning: The directory "+ filepath +" already exists")
   return filepath
353071
def get_file(self, user, handle):
        
        user_dir = self.user_dir(user)
        if not user_dir.exists():
            return None

        if not is_valid_handle(handle):
            return None

        file_path = user_dir / handle

        if not file_path.exists() and not file_path.is_file():
            return None

        return file_path
570314
def _keepVol(self, vol):
        
        if vol is None:
            return

        if vol in self.extraVolumes:
            del self.extraVolumes[vol]
            return

        if vol not in self.paths:
            raise Exception("%s not in %s" % (vol, self))

        paths = [os.path.basename(path) for path in self.paths[vol]]
        newPath = self.selectReceivePath(paths)

        if self._skipDryRun(logger, 'INFO')("Copy %s to %s", vol, newPath):
            return

        self.butterVolumes[vol.uuid].copy(newPath)
1330868
def _find_file(self, path, saltenv='base'):
        '''
        
        '''
        fnd = {'path': '',
               'rel': ''}

        if salt.utils.url.is_escaped(path):
            # The path arguments are escaped
            path = salt.utils.url.unescape(path)
        for root in self.opts['pillar_roots'].get(saltenv, []):
            full = os.path.join(root, path)
            if os.path.isfile(full):
                fnd['path'] = full
                fnd['rel'] = path
                return fnd
        return fnd
751198
def get_path_type(path_):
    
    """
    path_type = ''
    if isfile(path_):
        path_type += 'file'
    if isdir(path_):
        path_type += 'directory'
    if islink(path_):
        path_type += 'link'
    if ismount(path_):
        path_type += 'mount'
    return path_type
334702
def is_file(self, path):
        """"""
        return (samefile(path, self.device_file) or
                samefile(path, self.loop_file) or
                any(samefile(path, mp) for mp in self.mount_paths) or
                sameuuid(path, self.id_uuid) or
                sameuuid(path, self.partition_uuid))