$snapcount = keys %{$table};
print "Snapcount $snapcount\n";
+
+ if ( ! defined $table->{0} ) {
+ print "No current snapshot in table! First make one\n";
+ return ;
+ }
$data = pack("iii", $snapdev, $snapno, $snapcount);
$datalen = 3 * 4;
foreach my $time (sort keys %{$table}) {
my $cl = length($data);
my $add = pack("p", $data);
print "type $type (len $len), datalen $datalen ($cl)\n";
- printf "Addr of data %x\n", $add;
my $packed = pack("ipip", length($type), $type, $datalen, $data);
my $rc = ioctl(DEV_OBD, &OBD_IOC_ATTACH, $packed);
goto again;
add:
- my $idx = &readl("enter new index: ");
- my $time = &readl("enter time (hit RET for \"now\"): ");
+ my $idx = &readl("enter index where you want this snapshot: ");
+ my $time = &readl("enter time or 'now' or 'current': ");
my $oldtime = SnapFindTimeFromIdx($idx, $table);
- delete $table->{$oldtime} if defined $oldtime;
- $time = time unless $time;
+ if (defined $oldtime) {
+ print "This already exists, first clean up\n";
+ goto again;
+ }
+
+ if ( $time eq 'now' ) {
+ $time = time;
+ } elsif ( $time eq 'current' ) {
+ $time = 0;
+ }
$table->{$time} = $idx;
goto again;
foreach $time ( sort keys %{$table} ) {
my $stime = localtime($time);
+ if ( ! $time ) {
+ $stime = "current";
+ }
printf "Time: %s -- Index %d\n", $stime, $table->{$time};
}
}
$table->{$time} = $index;
}
close FH;
+
+ PrintSnapShotTable($table);
+
return $table;
}