From 73108d2309133282870bcabc2d53e28edae80623 Mon Sep 17 00:00:00 2001 From: Axel Burri Date: Sun, 4 Aug 2019 13:49:19 +0200 Subject: [PATCH] btrbk: fix: "readonly" is required key for "btrfs subvolume show" output The "Flags: readonly|-" line is present as of btrfs-progs v4.6.1, and is required in "target metadata check" of btrfs_send_receive(). --- btrbk | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/btrbk b/btrbk index 4339b7b..7a3c364 100755 --- a/btrbk +++ b/btrbk @@ -1006,12 +1006,16 @@ sub btrfs_subvolume_show($;@) } DEBUG "Parsed " . scalar(keys %detail) . " subvolume detail items: $vol->{PRINT}"; + # NOTE: as of btrfs-progs v4.6.1, flags are either "-" or "readonly" + $detail{readonly} = ($detail{flags} =~ /readonly/) ? 1 : 0 if($detail{flags}); + # validate required keys unless((defined($detail{parent_uuid}) && (($detail{parent_uuid} eq '-') || ($detail{parent_uuid} =~ /^$uuid_match$/))) && (defined($detail{id}) && ($detail{id} =~ /^\d+$/) && ($detail{id} >= 5)) && (defined($detail{gen}) && ($detail{gen} =~ /^\d+$/)) && (defined($detail{cgen}) && ($detail{cgen} =~ /^\d+$/)) && - (defined($detail{top_level}) && ($detail{top_level} =~ /^\d+$/))) + (defined($detail{top_level}) && ($detail{top_level} =~ /^\d+$/)) && + (defined($detail{readonly}))) { ERROR "Failed to parse subvolume detail (unsupported btrfs-progs) for: $vol->{PRINT}"; return undef; @@ -1036,9 +1040,6 @@ sub btrfs_subvolume_show($;@) return undef; } - # NOTE: as of btrfs-progs v4.6.1, flags are either "-" or "readonly" - $detail{readonly} = ($detail{flags} =~ /readonly/) ? 1 : 0; - VINFO(\%detail, "detail") if($loglevel >=4); }