btrsync.btrfs¶
Data structures and functions manipulating btrfs subvolumes.
Module Attributes
Path of the btrfs filesystem root, as printed by |
- btrsync.btrfs.FSTREE = '<FS_TREE>'¶
Path of the btrfs filesystem root, as printed by
btrfs-progs.
Functions
|
Process a sequence of btrfs volumes, making all relative paths absolute; absolute paths are left unchanged. |
|
Process a sequence of btrfs volumes, making all paths below a chosen root relative to that root; other paths are left unchanged. |
- btrsync.btrfs.abspaths(vols, rootpath)[source]¶
Process a sequence of btrfs volumes, making all relative paths absolute; absolute paths are left unchanged.
- Parameters
vols – the sequence of btrfs subvolumes to process
rootpath – the absolute path that subvolume paths are relative to
- Returns
iterator over the modified subvolumes
- Raises
ValueError – if rootpath is not absolute (does not start with
FSTREE)
- btrsync.btrfs.relpaths(vols, rootpath)[source]¶
Process a sequence of btrfs volumes, making all paths below a chosen root relative to that root; other paths are left unchanged.
- Parameters
vols – the sequence of btrfs subvolumes to process
rootpath – the absolute path that subvolume paths are to be made relative to
- Returns
iterator over the modified subvolumes
- Raises
ValueError – if rootpath is not absolute (does not start with
FSTREE)
Classes
|
Build a hierarchy of btrfs subvolumes based on snapshotting (COW) parentage. |
|
Helper class for manipulating btrfs subvolumes. |
- class btrsync.btrfs.COWTree(subvols, check=None)[source]¶
Build a hierarchy of btrfs subvolumes based on snapshotting (COW) parentage.
- Parameters
subvols – the sequence of subvolumes (
dictinstances keyed by subvolume properties) to processcheck – a function that takes a subvolume as argument and returns a boolean whether to consider it for parentage; by default accept all
- static bfs(*nodes, **kwargs)[source]¶
Iterate, in a breadth-first search, over nodes and their COW descendants.
- static diff(aroots, broots, akeys, bkeys)[source]¶
Perform a diff operation over two sets of COW hierarchies, identifying common subvolumes based on custom key functions.
Two subvolumes are considered identical if any non-None results of their key functions match.
- Parameters
aroots – the first sequence of COW hierarchies to compare
broots – the second sequence of COW hierarchies to compare
akeys – the sequence of key functions to apply to aroots
bkeys – the sequence of key functions to apply to broots
- Returns
tuple of dicts (coma, comb), indexing, by subvolume uuid, the elements of aroots and broots respectively, which have corresponding identical subvolumes in the other set
- property roots¶
Roots of the computed COW hierarchy.
- class btrsync.btrfs.Vol(*args, parent=None, succs=[], **kwargs)[source]¶
Helper class for manipulating btrfs subvolumes.
Subvolumes are
dictinstances of (property: value) pairs. The properties exposed are those provided bybtrfs subvolume listwith the addition of computed COW parent and successors.- clear() None. Remove all items from D.¶
- copy() a shallow copy of D¶
- fromkeys(value=None, /)¶
Create a new dictionary with keys from iterable and values set to value.
- get(key, default=None, /)¶
Return the value for key if key is in the dictionary, else default.
- items() a set-like object providing a view on D's items¶
- keys() a set-like object providing a view on D's keys¶
- property parent¶
COW parent of this subvolume, or
Noneif self-standing.
- pop(k[, d]) v, remove specified key and return the corresponding value.¶
If key is not found, d is returned if given, otherwise KeyError is raised
- popitem() (k, v), remove and return some (key, value) pair as a¶
2-tuple; but raise KeyError if D is empty.
- setdefault(key, default=None, /)¶
Insert key with a value of default if key is not in the dictionary.
Return the value for key if key is in the dictionary, else default.
- property succs¶
Volumes for which this subvolume is a COW parent.
- update([E, ]**F) None. Update D from dict/iterable E and F.¶
If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]
- values() an object providing a view on D's values¶
Modules
Programmatically generate |
|
Parsers for the output of |