Esempio n. 1
0
    def _remove_handle(self, path):
        _hash_path = hash_path(path)

        handle = self.store.remove(_hash_path)
        if handle is not None:
            parent, name = os.path.split(path)

            if handle[3] == 1:
                self.store.remove('l_' + _hash_path)

            parent_hash = hash_path(parent)
            parent_l = self.store.get("l_" + parent_hash)
            if name in parent_l:
                parent_l.remove(name)
                self.store.put("l_" + parent_hash, parent_l)

        return handle
Esempio n. 2
0
    def _rename_handle(self, old, new):
        parent, name = _split_path(new)

        self._remove_handle(new)

        parent, old_name = os.path.split(old)

        parent_hash = hash_path(parent)
        parent_l = self.store.get("l_" + parent_hash)
        parent_l.remove(old_name)
        parent_l.append(name)
        self.store.put("l_" + parent_hash, parent_l)

        handle = self._remove_handle(old)
        handle = self._copy_handle(handle, key=hash_path(new), name=name)

        self.store.put(handle[0], handle)
Esempio n. 3
0
    def __init__(self, root, mount_point):
        self.root = root
        self.mount_point = mount_point

        db_path = self.root + '/.store.db'

        st_dict = self._get_st_dict(os.lstat(self.root))
        self.gid = st_dict['st_gid']
        self.uid = st_dict['st_uid']

        stv = self._get_st_dict(os.lstat(self.root))

        self.store = HandleStore(db_path, stv)

        handle = self._get_handle_path('/')
        if handle is None:
            handle = (hash_path('/'), '/', None, 1, stv, None)
            self.store.put(hash_path('/'), handle)
Esempio n. 4
0
    def _create_handle(self, path, is_dir, dir_stv=None, link_path=None):
        dir_flag = 0
        if is_dir:
            dir_flag = 1

        parent, name = _split_path(path)

        handle = (hash_path(path), name, parent, dir_flag, dir_stv, link_path)

        self.store.put(handle[0], handle)
        if is_dir:
            self.store.put("l_" + handle[0], [])

        parent_dir_key = "l_" + hash_path("/" + handle[2])
        _dir = self.store.get(parent_dir_key)
        _dir.append(handle[1])

        self.store.put(parent_dir_key, _dir)

        return handle
Esempio n. 5
0
    def symlink(self, name, target):
        handle = self._get_handle_path(name)
        if handle is not None:
            raise FuseOSError(errno.ENOANO)

        path = os.path.abspath(os.path.join(self.mount_point, "." + os.path.split(name)[0], target))

        if path.startswith(self.mount_point):
            fuse_path = path[len(self.mount_point):]
            res = os.symlink(hash_path(fuse_path), self._full_path(name))
        else:
            res = os.symlink(path, self._full_path(name))

        self._create_handle(name, False, link_path=target)

        return res
Esempio n. 6
0
 def _list_dir(self, path):
     return self.store.get("l_" + hash_path(path))
Esempio n. 7
0
 def _get_handle_path(self, path):
     return self._get_handle_hash(hash_path(path))
Esempio n. 8
0
 def _full_path(self, partial):
     path = self._get_full_path_hash(hash_path(partial))
     return path