Skip to content
This repository has been archived by the owner on Jun 7, 2022. It is now read-only.

Commit

Permalink
Fixes (#48)
Browse files Browse the repository at this point in the history
* Version bump

* Fixed #46

* Fixed #47

* Updated changelog

* Code refactoring

* Improved warning message

* Code refactoring and wording fix
  • Loading branch information
darrenldl committed Mar 24, 2018
1 parent b6f826f commit 72c67e4
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 34 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 1.0.2
- Fixed wording of error correction parameters interpretation strings in calc mode
- Fixed container size calculation for when file size is 0
- Previously for RS enabled SBX versions, rsbx would fail to take burst gaps between metadata blocks into account

## 1.0.1
- Added displaying of metadata block repairs in repair mode when verbose flag is supplied

Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "rsbx"
version = "1.0.1"
version = "1.0.2"
authors = ["Darren Ldl <darrenldldev@gmail.com>"]
build = "build.rs"
exclude = [
Expand Down
60 changes: 37 additions & 23 deletions src/cli_calc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,30 +119,44 @@ pub fn calc<'a>(matches : &ArgMatches<'a>) -> i32 {
println!("Error correction parameters interpretation");
println!("========================================");
if burst == 0 {
println!(" The container can tolerate corruption of {} SBX blocks(totalling {} bytes) in
every set of {} consecutive blocks({} bytes).",
par,
par * block_size,
data + par,
(data + par) * block_size);
print_block!(
" The container can tolerate {} SBX block corruptions", par;
" in any block set.";
"";
" A block set consists of {} blocks({} bytes).", (data + par), (data + par) * block_size;
"";
" In total, {} blocks({} bytes) may be corrupted in", par, par * block_size;
" any block set.";
);
} else {
println!(" The container can tolerate {} burst SBX block corruptions in
every set of {} consecutive blocks({} bytes).
Each burst error may be up to {} blocks({} bytes) in size.
In total, {} bytes(aligned at block boundary) may be corrupted in
any set of {} consecutive blocks({} bytes).",
par,
(data + par) * burst,
(data + par) * burst * block_size,
burst,
burst * block_size,
par * burst * block_size,
(data + par) * burst,
(data + par) * burst * block_size);
println!();
println!(" Note that the actual tolerance depends on the behaviour of the file system.");
if burst == 1 {
print_block!(
" Warning :";
"";
" Burst error resistance level of {} may not provide", burst;
" meaningful resistance";
"";
);
}

let block_set_size = data + par;
let super_block_set_size = (data + par) * burst;

print_block!(" The container can tolerate {} burst SBX block corruptions in", par;
" any super block set({} interleaved block sets).", burst;
"";
" A block set consists of {} blocks({} bytes).", block_set_size, block_set_size * block_size;
"";
" A super block set consists of {} blocks({} bytes).", super_block_set_size, super_block_set_size * block_size;
"";
" Each burst error may be up to {} blocks({} bytes) in size.", burst, burst * block_size;
"";
" In total, {} sets of {} consecutive blocks({} bytes) may be", par, burst, burst * block_size;
" corrupted in any super block set.";
"";
" Note that the actual tolerance depends on the behaviour of";
" the file system.";
);
}

println!();
Expand Down
13 changes: 11 additions & 2 deletions src/file_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,18 @@ pub mod from_orig_file_size {
size);

if data_block_count == 0 {
let meta_block_count = 1 + parity as u64;
let mut max_file_size = 0;
for &p in sbx_block::calc_meta_block_all_write_pos_s(version,
data_par_burst).iter()
{
let file_size = p + block_size;

if file_size > max_file_size {
max_file_size = file_size;
}
}

return block_size * meta_block_count
return max_file_size;
}

let last_seq_num = data_block_count as u32;
Expand Down
11 changes: 7 additions & 4 deletions src/repair_core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,10 +238,13 @@ pub fn repair_file(param : &Param)
None => {
print_block!(
"";
"Warning : No recorded file size found, using container file size to estimate total";
" number of blocks. This may overestimate total number of blocks, and may";
" show false repair/verify failures when gaps in container are encountered.";
"";);
"Warning :";
"";
" No recorded file size found, using container file size to estimate total";
" number of blocks. This may overestimate total number of blocks, and may";
" show false repair/verify failures when gaps in container are encountered.";
"";
);
let metadata = file_utils::get_file_metadata(&param.in_file)?;
metadata.len() / block_size as u64
},
Expand Down
6 changes: 3 additions & 3 deletions src/sbx_block/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,10 @@ mod parsers {
named!(pub header_p <Header>,
do_parse!(
_sig : sig_p >>
version : ver_p >>
crc : be_u16 >>
version : ver_p >>
crc : be_u16 >>
uid_raw : uid_p >>
seq_num : be_u32 >>
seq_num : be_u32 >>
({
let mut uid : [u8; 6] = [0; 6];
uid.copy_from_slice(uid_raw);
Expand Down

0 comments on commit 72c67e4

Please sign in to comment.