Added sub to mark blocks used.

This commit is contained in:
Leeland Heins 2019-03-04 10:50:49 -06:00 committed by GitHub
parent c22e68e1b7
commit 5b1fbef973
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 22 additions and 0 deletions

View File

@ -1554,6 +1554,28 @@ sub rename_file {
return 1;
}
#
# Reserve a list of used blocks.
#
sub reserve_blocks {
my ($pofile, $used_blocks, $dbg) = @_;
$debug = 1 if defined $dbg && $dbg;
# Get the volume bit map (blocks used/free).
my (@bitmaps) = get_vol_bit_map($pofile, $debug);
# Mark blocks in list as used in the bit map.
foreach my $cur_blk (@{$used_blocks}) {
#printf("cur_blk=%d byte=%d bit=%d\n", $cur_blk, $cur_blk / 8, $cur_blk % 8);
$bitmaps[$cur_blk / 8] &= ~(1 << ($cur_blk % 8));
last if $cur_blk == 0;
}
# Now write the volume bit map back out.
return write_vol_bit_map($pofile, \@bitmaps, $debug);
}
#
# Free a list of blocks.
#