btrfs: add helper to iterate over snapshots of a subvolume
In this context a subvolume means a BTRFS subvolume. `$volume\@$snap_name` would be for example `btrfs_volume/images/102/vm-102-disk-0@snap_name`. Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
This commit is contained in:
committed by
Fiona Ebner
parent
70955c2d34
commit
171b760d81
@ -419,6 +419,20 @@ my sub foreach_subvol : prototype($$) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Calls `$code->($snapshot)` for each snapshot of the BTRFS subvolume.
|
||||||
|
my sub foreach_snapshot_of_subvol : prototype($$) {
|
||||||
|
my ($subvol, $code) = @_;
|
||||||
|
|
||||||
|
my $basename = basename($subvol);
|
||||||
|
my $dir = dirname($subvol);
|
||||||
|
foreach_subvol($dir, sub {
|
||||||
|
my ($volume, $name, $snapshot) = @_;
|
||||||
|
return if $name ne $basename;
|
||||||
|
return if !defined $snapshot;
|
||||||
|
$code->($snapshot);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
sub free_image {
|
sub free_image {
|
||||||
my ($class, $storeid, $scfg, $volname, $isBase, $_format) = @_;
|
my ($class, $storeid, $scfg, $volname, $isBase, $_format) = @_;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user