]> git.gag.com Git - debian/amanda/blobdiff - perl/Amanda/Application/Zfs.pm
Imported Upstream version 3.3.3
[debian/amanda] / perl / Amanda / Application / Zfs.pm
index 250b1ea19f3bb4d7f56e615f8de1330fb692edf5..ecd9b13c2d6b61dbf91810ca91e9f16cb9ee65ef 100644 (file)
@@ -1,8 +1,9 @@
-# Copyright (c) 2008, 2009, 2010 Zmanda, Inc.  All Rights Reserved.
+# Copyright (c) 2008-2012 Zmanda, Inc.  All Rights Reserved.
 #
-# This program is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 as published
-# by the Free Software Foundation.
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
 #
 # This program is distributed in the hope that it will be useful, but
 # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
@@ -197,11 +198,7 @@ sub zfs_set_value {
 
     }
 
-    if ($self->{action} eq 'check') {
-      $self->{snapshot} = $self->zfs_build_snapshotname($device, -1);
-    } else {
-      $self->{snapshot} = $self->zfs_build_snapshotname($device);
-    }
+    $self->{snapshot} = $self->zfs_build_snapshotname($device);
     if (defined $self->{mountpoint}) {
        if ($device =~ /^$self->{mountpoint}/) {
             $self->{dir} = $device;
@@ -310,7 +307,7 @@ sub zfs_rename_snapshot {
     my $device = $self->{device};
     $device = $self->{directory} if defined $self->{directory};
     my $newsnapshotname = $self->zfs_build_snapshotname($device, $level);
-    my $cmd = "$self->{pfexec_cmd} $self->{zfs_path} rename $self->{filesystem}\@$self->{snapshot} $newsnapshotname";
+    my $cmd = "$self->{pfexec_cmd} $self->{zfs_path} rename $self->{filesystem}\@$self->{snapshot} $self->{filesystem}\@$newsnapshotname";
     debug "running: $cmd|";
     my($wtr, $rdr, $err, $pid);
     my($msg, $errmsg);
@@ -380,15 +377,13 @@ sub zfs_build_snapshotname {
 
     my $snapshotname = "";
 
-    if (!defined $level) {
-      $snapshotname = "amanda-" . Amanda::Util::sanitise_filename($self->{disk}) . "-current";
-    } else {
-      if ($level < 0) {
+    if ($self->{action} eq 'check') {
        $snapshotname = "amanda-" . Amanda::Util::sanitise_filename($self->{disk}) . "-check";
-      } else {
-        $snapshotname = "amanda-" . Amanda::Util::sanitise_filename($self->{disk}) . "-" . $level;
-      }
-    } 
+    } elsif (!defined $level) {
+       $snapshotname = "amanda-" . Amanda::Util::sanitise_filename($self->{disk}) . "-current";
+    } else {
+       $snapshotname = "amanda-" . Amanda::Util::sanitise_filename($self->{disk}) . "-" . $level;
+    }
 
     return $snapshotname;
 }