btrbk: be harsh, remove sroot, droot, svol in config (will break a lot of things!)

pull/73/head
Axel Burri 2016-03-07 17:46:53 +01:00
parent d3148851c5
commit 96faae9659
1 changed files with 20 additions and 19 deletions

39
btrbk
View File

@ -813,13 +813,13 @@ sub parse_config_line($$$$$)
$value =~ s/\/+$// unless($value =~ /^\/+$/); # remove trailing slash $value =~ s/\/+$// unless($value =~ /^\/+$/); # remove trailing slash
$value =~ s/^\/+/\//; # sanitize leading slash $value =~ s/^\/+/\//; # sanitize leading slash
TRACE "config: adding volume \"$value\" to root context"; TRACE "config: adding volume \"$value\" to root context";
die unless($cur->{CONTEXT} eq "root");
my $volume = { CONTEXT => "volume", my $volume = { CONTEXT => "volume",
PARENT => $cur, PARENT => $cur,
url => $value, url => $value,
}; };
$cur->{VOLUME} //= []; $cur->{SUBSECTION} //= [];
$cur->{SUBSECTION} //= $cur->{VOLUME}; push(@{$cur->{SUBSECTION}}, $volume);
push(@{$cur->{VOLUME}}, $volume);
$cur = $volume; $cur = $volume;
} }
elsif($key eq "subvolume") elsif($key eq "subvolume")
@ -840,15 +840,15 @@ sub parse_config_line($$$$$)
TRACE "config: adding subvolume \"$value\" to volume context: $cur->{url}"; TRACE "config: adding subvolume \"$value\" to volume context: $cur->{url}";
my $snapshot_name = $value; my $snapshot_name = $value;
$snapshot_name =~ s/^.*\///; # snapshot_name defaults to subvolume name $snapshot_name =~ s/^.*\///; # snapshot_name defaults to subvolume name
die unless($cur->{CONTEXT} eq "volume");
my $subvolume = { CONTEXT => "subvolume", my $subvolume = { CONTEXT => "subvolume",
PARENT => $cur, PARENT => $cur,
rel_path => $value, rel_path => $value,
url => $cur->{url} . '/' . $value, url => $cur->{url} . '/' . $value,
snapshot_name => $snapshot_name, snapshot_name => $snapshot_name,
}; };
$cur->{SUBVOLUME} //= []; $cur->{SUBSECTION} //= [];
$cur->{SUBSECTION} //= $cur->{SUBVOLUME}; push(@{$cur->{SUBSECTION}}, $subvolume);
push(@{$cur->{SUBVOLUME}}, $subvolume);
$cur = $subvolume; $cur = $subvolume;
} }
elsif($key eq "target") elsif($key eq "target")
@ -874,14 +874,14 @@ sub parse_config_line($$$$$)
$droot =~ s/\/+$//; # remove trailing slash $droot =~ s/\/+$//; # remove trailing slash
$droot =~ s/^\/+/\//; # sanitize leading slash $droot =~ s/^\/+/\//; # sanitize leading slash
TRACE "config: adding target \"$droot\" (type=$target_type) to subvolume context: $cur->{url}"; TRACE "config: adding target \"$droot\" (type=$target_type) to subvolume context: $cur->{url}";
die unless($cur->{CONTEXT} eq "subvolume");
my $target = { CONTEXT => "target", my $target = { CONTEXT => "target",
PARENT => $cur, PARENT => $cur,
target_type => $target_type, target_type => $target_type,
url => $droot, url => $droot,
}; };
$cur->{TARGET} //= []; $cur->{SUBSECTION} //= [];
$cur->{SUBSECTION} //= $cur->{TARGET}; push(@{$cur->{SUBSECTION}}, $target);
push(@{$cur->{TARGET}}, $target);
$cur = $target; $cur = $target;
} }
else else
@ -2647,27 +2647,28 @@ MAIN:
ERROR "Failed to parse configuration file"; ERROR "Failed to parse configuration file";
exit 2; exit 2;
} }
unless(ref($config->{VOLUME}) eq "ARRAY") { #!!! check this below
ERROR "No volumes defined in configuration file"; # unless(ref($config->{VOLUME}) eq "ARRAY") {
exit 2; # ERROR "No volumes defined in configuration file";
} # exit 2;
# }
# #
# create vinfo nodes (no readin yet) # create vinfo nodes (no readin yet)
# #
foreach my $config_vol (@{$config->{VOLUME}}) { foreach my $config_vol (@{$config->{SUBSECTION}}) {
die unless($config_vol->{CONTEXT} eq "volume");
my $sroot = vinfo($config_vol->{url}, $config_vol); my $sroot = vinfo($config_vol->{url}, $config_vol);
vinfo_assign_config($sroot, $config_vol); vinfo_assign_config($sroot, $config_vol);
$config_vol->{sroot} = $sroot; #!!! foreach my $config_subvol (@{$config_vol->{SUBSECTION}}) {
foreach my $config_subvol (@{$config_vol->{SUBVOLUME}}) { die unless($config_subvol->{CONTEXT} eq "subvolume");
my $svol = vinfo_child($sroot, $config_subvol->{rel_path}); my $svol = vinfo_child($sroot, $config_subvol->{rel_path});
vinfo_assign_config($svol, $config_subvol); vinfo_assign_config($svol, $config_subvol);
$config_subvol->{svol} = $svol; #!!! foreach my $config_target (@{$config_subvol->{SUBSECTION}}) {
foreach my $config_target (@{$config_subvol->{TARGET}}) { die unless($config_target->{CONTEXT} eq "target");
my $droot = vinfo($config_target->{url}, $config_target); my $droot = vinfo($config_target->{url}, $config_target);
vinfo_assign_config($droot, $config_target); vinfo_assign_config($droot, $config_target);
$config_target->{droot} = $droot; #!!!
} }
} }
} }