mirror of https://github.com/digint/btrbk
btrbk: new implementation of btr_subtree(), using more complete information from btr_tree(). (unfinished)
parent
618114e717
commit
7497e0b561
52
btrbk
52
btrbk
|
@ -644,6 +644,12 @@ sub btr_tree($;$)
|
||||||
die unless($rel_path =~ s/^$top_level->{FIXED_PATH}\///);
|
die unless($rel_path =~ s/^$top_level->{FIXED_PATH}\///);
|
||||||
}
|
}
|
||||||
$node->{REL_PATH} = $rel_path;
|
$node->{REL_PATH} = $rel_path;
|
||||||
|
|
||||||
|
# !!! hack, remove
|
||||||
|
$node->{SUBVOL_PATH} = $rel_path;
|
||||||
|
TRACE "btr_tree: set SUBVOL_PATH: $node->{SUBVOL_PATH}";
|
||||||
|
$node->{FS_PATH} = $vol . "/" . $path;
|
||||||
|
TRACE "btr_tree: set FS_PATH: $node->{FS_PATH}";
|
||||||
}
|
}
|
||||||
|
|
||||||
# set PARENT node
|
# set PARENT node
|
||||||
|
@ -653,6 +659,32 @@ sub btr_tree($;$)
|
||||||
return \%tree;
|
return \%tree;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub set_correct_tree_path($)
|
||||||
|
{
|
||||||
|
my $tree = shift;
|
||||||
|
|
||||||
|
foreach my $node (values %$tree) {
|
||||||
|
if($node->{TOP_LEVEL}) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
sub _subtree_list
|
||||||
|
{
|
||||||
|
my $tree = shift;
|
||||||
|
my $subvols = shift;
|
||||||
|
my $prefix = shift;
|
||||||
|
|
||||||
|
return unless $subvols;
|
||||||
|
|
||||||
|
foreach(values %$subvols) {
|
||||||
|
my $path = $prefix . $_->{REL_PATH};
|
||||||
|
$tree->{$path} = $_;
|
||||||
|
_subtree_list($tree, $_->{SUBVOLUME}, $path . '/');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
sub btr_subtree($;$)
|
sub btr_subtree($;$)
|
||||||
{
|
{
|
||||||
|
@ -664,6 +696,26 @@ sub btr_subtree($;$)
|
||||||
return undef;
|
return undef;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
my $tree = btr_tree($vol, $config);
|
||||||
|
my $tree_root = $detail->{is_root} ? $tree : $uuid_info{$detail->{uuid}}->{SUBVOLUME};
|
||||||
|
die unless $tree_root;
|
||||||
|
|
||||||
|
my $ret = {};
|
||||||
|
_subtree_list($ret, $tree_root, "");
|
||||||
|
|
||||||
|
return $ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
sub btr_subtree_old($;$)
|
||||||
|
{
|
||||||
|
my $vol = shift || die;
|
||||||
|
my $config = shift;
|
||||||
|
my $detail = btr_subvolume_detail($vol, $config);
|
||||||
|
unless($detail) {
|
||||||
|
WARN "Failed to build btrfs subtree for volume: $vol";
|
||||||
|
return undef;
|
||||||
|
}
|
||||||
|
|
||||||
my $volname = $detail->{name} || "";
|
my $volname = $detail->{name} || "";
|
||||||
my %tree;
|
my %tree;
|
||||||
my $subvol_list = btr_subvolume_list($vol, $config, subvol_only => 1);
|
my $subvol_list = btr_subvolume_list($vol, $config, subvol_only => 1);
|
||||||
|
|
Loading…
Reference in New Issue