Debian Codegraph @

bin/btrfs/free_space_tree.py

raw symbols SCIP
1 # Copyright (C) 2017 Hans van Kranenburg <[email protected]>
2 #
3 # This file is part of the python-btrfs module.
4 #
5 # python-btrfs is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU Lesser General Public License as published by
7 # the Free Software Foundation, either version 3 of the License, or
8 # (at your option) any later version.
9 #
10 # python-btrfs is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU Lesser General Public License for more details.
14 #
15 # You should have received a copy of the GNU Lesser General Public License
16 # along with python-btrfs. If not, see <http://www.gnu.org/licenses/>.
17
18
19 class FreeSpaceExtent():
20 """Helper object for listing free space tree extents.
21
22 In the free space tree, information about free space can be stored as free
23 space extent item, in which case it has information about a single gap of
24 free space. Alternatively, it can be stored in a compacted format, as free
25 space bitmap. In that case, to find out where the tiny gaps of free space
26 are located, the bitmap needs to be unpacked.
27
28 This object serves as a helper when doing so. It is used by the
29 :func:`~btrfs.ctree.FreeSpaceBitmap.unpack` function of a
30 :class:`btrfs.ctree.FreeSpaceBitmap`. It's also used by the
31 :func:`~btrfs.ctree.FileSystem.free_space_extents` convenience method of a
32 :class:`btrfs.ctree.FileSystem` object for generating a simple stream of free
33 space extent info transparently unpacking bitmaps.
34
35 :ivar int vaddr: Logical address of the start of the free space extent.
36 :ivar int length: Length of the free space extent.
37 """
38 def __init__(self, vaddr, length):
39 self.vaddr = vaddr
40 self.length = length
41
42 def __str__(self):
43 return "free space extent vaddr {self.vaddr} length {self.length}".format(self=self)