Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ebolwidt committed Mar 5, 2011
1 parent 8d62682 commit 4baf15a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
5 changes: 3 additions & 2 deletions lib/blockdev/devmapper.rb
Expand Up @@ -38,8 +38,8 @@ def self.unmap_partitions_to_devices(path)

def self.get_mapping(path)
path = path.path if (path.is_a? File)
output = KernelExt::fork_exec_get_output(@kpartx_path, file)
mapping = Mapping.new(file)
output = KernelExt::fork_exec_get_output(@kpartx_path, path)
mapping = Mapping.new(path)
output.scan /^(\S+)\s*:\s*\d+\s+\d+\s+(\S+)\s+\d+$/ do |m|
if (mapping.device.nil?)
mapping.device = $2
Expand Down Expand Up @@ -72,6 +72,7 @@ def self.unmap_partitions_to_devices_kpartx(path)
path = path.path if (path.is_a? File)
devices = Loop::devices_for(path)
devices.each do |device|
puts(@kpartx_path, "-d", device)
KernelExt::fork_exec_no_output(@kpartx_path, "-d", device)
Loop::remove(device)
end
Expand Down
4 changes: 2 additions & 2 deletions lib/blockdev/loop.rb
Expand Up @@ -18,7 +18,7 @@ def self.add(path, read_only = false, offset = nil, size = nil)
args.push("--sizelimit", size)
end
args.push("-f", path)
line = KernelExt::fork_exec_get_output(args)
line = KernelExt::fork_exec_get_output(*args)
line.strip
end

Expand Down Expand Up @@ -66,7 +66,7 @@ def self.device_for(path)

def self.devices_for(path)
path = path.path if (path.is_a? File)
loop_devs = loop_devices
loop_devs = devices
loop_devs.reject! { |dev| file_name_for(dev) != path }
loop_devs
end
Expand Down
11 changes: 11 additions & 0 deletions sandbox/hlpartitiontable_unmap.rb
@@ -0,0 +1,11 @@
$:.unshift File.join(File.dirname(__FILE__), '..', 'lib')

require 'rubygems'
require 'hl-partition.rb'
require 'file/file_patch.rb'
require 'debootstrap/debootstrap.rb'

#path = "tmp/highlevel.img"
path = "/home/vmplanet/cabochon/tmp/highlevel.img"

DevMapper.unmap_partitions_to_devices(path)

0 comments on commit 4baf15a

Please sign in to comment.