Merge tag 'upstream/3.3.3'
[debian/amanda] / perl / Amanda / Tapelist.swg
index d15217abfc8d09f90f2912153ca261db30a4e5ec..dff9b86177670c29bc87d27f932f68c1eb925de7 100644 (file)
@@ -1,9 +1,10 @@
 /*
- * 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
@@ -124,7 +125,7 @@ sub remove_tapelabel {
 
 sub add_tapelabel {
     my $self = shift;
-    my ($datestamp, $label, $comment, $reuse, $meta, $barcode) = @_;
+    my ($datestamp, $label, $comment, $reuse, $meta, $barcode, $blocksize) = @_;
     $reuse = 1 if !defined $reuse;
 
     # prepend this (presumably new) volume to the beginning of the list
@@ -134,6 +135,7 @@ sub add_tapelabel {
         'reuse'     => $reuse,
         'barcode'   => $barcode,
         'meta'      => $meta,
+        'blocksize' => $blocksize,
         'comment'   => $comment,
     };
     my $tles = $self->{'tles'};
@@ -172,8 +174,9 @@ sub write {
        my $reuse = $tle->{'reuse'} ? 'reuse' : 'no-reuse';
        my $barcode = (defined $tle->{'barcode'})? (" BARCODE:" . $tle->{'barcode'}) : '';
        my $meta = (defined $tle->{'meta'})? (" META:" . $tle->{'meta'}) : '';
+       my $blocksize = (defined $tle->{'blocksize'})? (" BLOCKSIZE:" . $tle->{'blocksize'}) : '';
        my $comment = (defined $tle->{'comment'})? (" #" . $tle->{'comment'}) : '';
-       $result &&= print $fhn "$datestamp $label $reuse$barcode$meta$comment\n";
+       $result &&= print $fhn "$datestamp $label $reuse$barcode$meta$blocksize$comment\n";
     }
     my $result_close = close($fhn);
     $result &&= $result_close;
@@ -225,15 +228,18 @@ sub _read_tapelist {
     my @tles;
     open(my $fh, "<", $self->{'filename'}) or return $self;
     while (my $line = <$fh>) {
-       my ($datestamp, $label, $reuse, $barcode, $meta, $comment)
-           = $line =~ m/^([0-9]*)\s([^\s]*)\s(reuse|no-reuse)\s*(?:BARCODE:([^\s]*))?\s*(?:META:([^\s]*))?\s*(?:\#(.*))?$/mx;
-       next if !defined $datestamp; # silently filter out bogus lines
+       my ($datestamp, $label, $reuse, $barcode, $meta, $blocksize, $comment)
+           = $line =~ m/^([0-9]+)\s*([^\s]*)\s*(?:(reuse|no-reuse))?\s*(?:BARCODE:([^\s]*))?\s*(?:META:([^\s]*))?\s*(?:BLOCKSIZE:([^\s]*))?\s*(?:\#(.*))?$/mx;
+       if (!defined $datestamp) {
+           Amanda::Debug::critical("Bogus line in the tapelist ($self->{'filename'}) file: $line");
+       }
        push @tles, {
            'datestamp' => $datestamp,
            'label' => $label,
-           'reuse' => ($reuse eq 'reuse'),
+           'reuse' => (!defined $reuse || $reuse eq 'reuse'),
            'barcode' => $barcode,
            'meta' => $meta,
+           'blocksize' => $blocksize,
            'comment' => $comment,
        };
     }
@@ -266,6 +272,7 @@ sub _update_positions {
 %}
 
 char *get_last_reusable_tape_label(int skip);
+%newobject list_new_tapes;
 char *list_new_tapes(int nb);
 
 /* C functions -- should be called *only* from within this module */