amdumpext
changeset 3 75bddaf5ed89
parent 2 9c602f1fe522
equal deleted inserted replaced
2:9c602f1fe522 3:75bddaf5ed89
    27 );
    27 );
    28 
    28 
    29 # the commands we need to support as required by the
    29 # the commands we need to support as required by the
    30 # API:  http://wiki.zmanda.com/index.php/Application_API/Operations
    30 # API:  http://wiki.zmanda.com/index.php/Application_API/Operations
    31 
    31 
    32 sub exit_support;
    32 sub exec_support;
    33 sub exit_selfcheck;
    33 sub exec_selfcheck;
    34 sub exit_estimate;
    34 sub exec_estimate;
    35 sub exit_backup;
    35 sub exec_backup;
    36 
    36 
    37 # some helper functions
    37 # some helper functions
    38 
    38 
    39 sub device;
    39 sub device;
    40 sub OK;
    40 sub OK;
    74 
    74 
    75         'dumpdates=s' => \$opt_dumpdates,    # --dumpdates <file>
    75         'dumpdates=s' => \$opt_dumpdates,    # --dumpdates <file>
    76     ) or pod2usage(-message => "$0 @argv");
    76     ) or pod2usage(-message => "$0 @argv");
    77 
    77 
    78     given ($command) {
    78     given ($command) {
    79         when ("support")   { exit_support }
    79         when ("support")   { exec_support }
    80         when ("selfcheck") { exit_selfcheck }
    80         when ("selfcheck") { exec_selfcheck }
    81         when ("estimate")  { exit_estimate }
    81         when ("estimate")  { exec_estimate }
    82         when ("backup")    { exit_backup }
    82         when ("backup")    { exec_backup }
    83     }
    83     }
    84     pod2usage(-message => "$0 @argv");
    84     pod2usage(-message => "$0 @argv");
    85 }
    85 }
    86 
    86 
    87 # output a list of supported options
    87 # output a list of supported options
    88 sub exit_support {
    88 sub exec_support {
    89     print map {
    89     print map { "$_ $SUPPORT{$_}\n" =~ s/_/-/gr } keys %SUPPORT;
    90         map { y/_/-/; $_ }
       
    91           $_
       
    92           . " $SUPPORT{$_}\n"
       
    93     } keys %SUPPORT;
       
    94     exit 0;
    90     exit 0;
    95 }
    91 }
    96 
    92 
    97 sub exit_selfcheck {
    93 sub exec_selfcheck {
    98 
    94 
    99     if ($_ = (grep { -x ($_ .= "/dump") } split /:/ => $ENV{PATH})[0]) {
    95     if ($_ = (grep { -x ($_ .= "/dump") } split /:/ => $ENV{PATH})[0]) {
   100         OK "dump is \"$_\"";
    96         OK "dump is \"$_\"";
   101     }
    97     }
   102     else { say "ERROR dump not found in $ENV{PATH}\n" }
    98     else { say "ERROR dump not found in $ENV{PATH}\n" }
   119     }
   115     }
   120 
   116 
   121     exit 0;
   117     exit 0;
   122 }
   118 }
   123 
   119 
   124 sub exit_estimate {
   120 sub exec_estimate {
   125 
   121 
   126     # $opt_level, $opt_device
   122     # $opt_level, $opt_device
   127     my @cmd = (
   123     my @cmd = (
   128         dump => "-$opt_level",
   124         dump => "-$opt_level",
   129         "-S",
   125         "-S",
   144     # --> the blocksize unit is K
   140     # --> the blocksize unit is K
   145     say "$opt_level $output 1";
   141     say "$opt_level $output 1";
   146     exit 0;
   142     exit 0;
   147 }
   143 }
   148 
   144 
   149 sub exit_backup {
   145 sub exec_backup {
   150 
   146 
   151     # fd1: data channel
   147     # fd1: data channel
   152     # fd3: message channel
   148     # fd3: message channel
   153     # fd4: index channel
   149     # fd4: index channel
   154 
   150