thin_metadata_size: fix units

This commit is contained in:
Heinz Mauelshagen 2013-06-26 13:01:51 +02:00
parent 63c140d26e
commit 2631d377b5
2 changed files with 11 additions and 6 deletions

View File

@ -98,8 +98,8 @@ def single_mapping(from, to = 4711)
" <single_mapping time=\"0\" origin_block=\"#{from}\" data_block=\"#{to}\"/>\n"
end
def range_mapping(mapping, length)
" <range_mapping time=\"0\" origin_begin=\"#{mapping}\" data_begin=.\"1169\" length=\"#{lenght}\"/>\n"
def range_mapping(from, to, length)
" <range_mapping time=\"0\" origin_begin=\"#{from}\" data_begin=.\"#{to]\" length=\"#{length}\"/>\n"
end
def xml_metadata(opts, units)
@ -108,9 +108,14 @@ def xml_metadata(opts, units)
puts begin_superblock(opts[:blocksize], blocks)
0.step(opts[:thins] - 1) do |devid|
puts begin_device(devid, opts[:thinsize])
0.step(blocks - 1) do |from|
puts single_mapping(from, to)
to += 1
if opts[:range]
puts range_mapping(from, to, blocks)
to += blocks
else
0.step(blocks - 1) do |from|
puts single_mapping(from, to)
to += 1
end
end
puts end_device
end

View File

@ -27,7 +27,7 @@ def init_units
'petabytes', 'pebibytes', 'exabytes', 'ebibytes',
'zetabytes', 'zebibytes', 'yottabytes', 'yobibytes' ]
units[:factors] = [ 1, units[:bytes_per_sector] ]
1.step(8) { |e| units[:factors] += [ 1024**e, 1000**e ] }
1.step(8) { |e| units[:factors] += [ 1000**e, 1024**e ] }
units
end