|
| 1 | +From efd52f416d1ecf95c9e7db225476c6a5fd1d1808 Mon Sep 17 00:00:00 2001 |
| 2 | +From: Christoph Klaffl <christoph@phreaker.eu> |
| 3 | +Date: Tue, 12 Aug 2025 14:19:47 +0200 |
| 4 | +Subject: [PATCH] fixed file handle conflict |
| 5 | + |
| 6 | +--- |
| 7 | + sanoid | 15 +++++++-------- |
| 8 | + 1 file changed, 7 insertions(+), 8 deletions(-) |
| 9 | + |
| 10 | +diff --git a/sanoid b/sanoid |
| 11 | +index 4a713191..8e0d1861 100755 |
| 12 | +--- a/sanoid |
| 13 | ++++ b/sanoid |
| 14 | +@@ -1084,11 +1084,9 @@ sub init { |
| 15 | + @datasets = getchilddatasets($config{$section}{'path'}); |
| 16 | + DATASETS: foreach my $dataset(@datasets) { |
| 17 | + if (! @cachedatasets) { |
| 18 | +- push (@updatedatasets, $dataset); |
| 19 | ++ push (@updatedatasets, "$dataset\n"); |
| 20 | + } |
| 21 | + |
| 22 | +- chomp $dataset; |
| 23 | +- |
| 24 | + if ($zfsRecursive) { |
| 25 | + # don't try to take the snapshot ourself, recursive zfs snapshot will take care of that |
| 26 | + $config{$dataset}{'autosnap'} = 0; |
| 27 | +@@ -1691,7 +1689,7 @@ sub getchilddatasets { |
| 28 | + my $getchildrencmd = "$mysudocmd $zfs list -o name -t filesystem,volume -Hr $fs |"; |
| 29 | + if ($args{'debug'}) { print "DEBUG: getting list of child datasets on $fs using $getchildrencmd...\n"; } |
| 30 | + open FH, $getchildrencmd; |
| 31 | +- my @children = <FH>; |
| 32 | ++ chomp( my @children = <FH> ); |
| 33 | + close FH; |
| 34 | + |
| 35 | + # parent dataset is the first element |
| 36 | +@@ -1781,25 +1779,26 @@ sub addcachedsnapshots { |
| 37 | + |
| 38 | + copy($cache, "$cache.tmp") or die "Could not copy to $cache.tmp!\n"; |
| 39 | + |
| 40 | +- open FH, ">> $cache.tmp" or die "Could not write to $cache.tmp!\n"; |
| 41 | ++ open my $fh, ">> $cache.tmp" or die "Could not write to $cache.tmp!\n"; |
| 42 | + while((my $snap, my $details) = each(%taken)) { |
| 43 | + my @parts = split("@", $snap, 2); |
| 44 | + |
| 45 | + my $suffix = $parts[1] . "\tcreation\t" . $details->{time} . "\t-"; |
| 46 | + my $dataset = $parts[0]; |
| 47 | + |
| 48 | +- print FH "${dataset}\@${suffix}\n"; |
| 49 | ++ print $fh "${dataset}\@${suffix}\n"; |
| 50 | + |
| 51 | + if ($details->{recursive}) { |
| 52 | + my @datasets = getchilddatasets($dataset); |
| 53 | + |
| 54 | + foreach my $dataset(@datasets) { |
| 55 | +- print FH "${dataset}\@${suffix}\n"; |
| 56 | ++ print "${dataset}\@${suffix}\n"; |
| 57 | ++ print $fh "${dataset}\@${suffix}\n"; |
| 58 | + } |
| 59 | + } |
| 60 | + } |
| 61 | + |
| 62 | +- close FH; |
| 63 | ++ close $fh; |
| 64 | + |
| 65 | + # preserve mtime of cache for expire check |
| 66 | + my ($dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size, $atime, $mtime, $ctime, $blksize, $blocks) = stat($cache); |
0 commit comments