btrfs: rename volume regex
The regex only lists snapshots. Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
This commit is contained in:
committed by
Fiona Ebner
parent
d3b84d73fd
commit
cae30fef56
@ -405,14 +405,14 @@ my sub path_is_subvolume : prototype($) {
|
|||||||
return S_ISDIR($mode) && $ino == BTRFS_FIRST_FREE_OBJECTID;
|
return S_ISDIR($mode) && $ino == BTRFS_FIRST_FREE_OBJECTID;
|
||||||
}
|
}
|
||||||
|
|
||||||
my $BTRFS_VOL_REGEX = qr/((?:vm|base|subvol)-\d+-disk-\d+(?:\.subvol)?)(?:\@(\S+))$/;
|
my $BTRFS_SNAPSHOT_REGEX = qr/((?:vm|base|subvol)-\d+-disk-\d+(?:\.subvol)?)(?:\@(\S+))$/;
|
||||||
|
|
||||||
# Calls `$code->($volume, $name, $snapshot)` for each subvol in a directory matching our volume
|
# Calls `$code->($volume, $name, $snapshot)` for each subvol in a directory matching our volume
|
||||||
# regex.
|
# regex.
|
||||||
my sub foreach_subvol : prototype($$) {
|
my sub foreach_subvol : prototype($$) {
|
||||||
my ($dir, $code) = @_;
|
my ($dir, $code) = @_;
|
||||||
|
|
||||||
dir_glob_foreach($dir, $BTRFS_VOL_REGEX, sub {
|
dir_glob_foreach($dir, $BTRFS_SNAPSHOT_REGEX, sub {
|
||||||
my ($volume, $name, $snapshot) = ($1, $2, $3);
|
my ($volume, $name, $snapshot) = ($1, $2, $3);
|
||||||
return if !path_is_subvolume("$dir/$volume");
|
return if !path_is_subvolume("$dir/$volume");
|
||||||
$code->($volume, $name, $snapshot);
|
$code->($volume, $name, $snapshot);
|
||||||
@ -869,7 +869,7 @@ sub volume_import {
|
|||||||
$dh->rewind;
|
$dh->rewind;
|
||||||
while (defined(my $entry = $dh->read)) {
|
while (defined(my $entry = $dh->read)) {
|
||||||
next if $entry eq '.' || $entry eq '..';
|
next if $entry eq '.' || $entry eq '..';
|
||||||
next if $entry !~ /^$BTRFS_VOL_REGEX$/;
|
next if $entry !~ /^$BTRFS_SNAPSHOT_REGEX$/;
|
||||||
my ($cur_diskname, $cur_snapshot) = ($1, $2);
|
my ($cur_diskname, $cur_snapshot) = ($1, $2);
|
||||||
|
|
||||||
die "send stream included a non-snapshot subvolume\n"
|
die "send stream included a non-snapshot subvolume\n"
|
||||||
|
|||||||
Reference in New Issue
Block a user