create_xml_data: adjust filed order to thin_dumo format; fix nr_data_blocks

This commit is contained in:
Heinz Mauelshagen 2013-06-27 15:36:50 +02:00
parent 27faf671ee
commit dd8b9a7cd5

View File

@ -100,11 +100,11 @@ def end_device
end end
def single_mapping(from, to) def single_mapping(from, to)
" <single_mapping time=\"0\" origin_block=\"#{from}\" data_block=\"#{to}\"/>\n" " <single_mapping origin_block=\"#{from}\" data_block=\"#{to}\" time=\"0\"/>\n"
end end
def range_mapping(from, to, length) def range_mapping(from, to, length)
" <range_mapping time=\"0\" origin_begin=\"#{from}\" data_begin=\"#{to}\" length=\"#{length}\"/>\n" " <range_mapping origin_begin=\"#{from}\" data_begin=\"#{to}\" length=\"#{length}\" time=\"0\"/>\n"
end end
def blocks(opts) def blocks(opts)
@ -116,11 +116,17 @@ def this_blocks(opts)
end end
def xml_metadata(opts, units) def xml_metadata(opts, units)
to = 0 nr_data_blocks, to = 0, 0
blks = []
puts begin_superblock(opts[:blocksize], 2 * opts[:thins] * blocks(opts)) 0.step(opts[:thins] - 1) do
blks << this_blocks(opts)
nr_data_blocks += blks[-1]
end
puts begin_superblock(opts[:blocksize], nr_data_blocks)
0.step(opts[:thins] - 1) do |dev_id| 0.step(opts[:thins] - 1) do |dev_id|
b = this_blocks(opts) b = blks.shift
puts begin_device(dev_id, b) puts begin_device(dev_id, b)
if opts[:range] if opts[:range]
puts range_mapping(0, to, b) puts range_mapping(0, to, b)