Update to check for mount points before checking firmlinks

This commit is contained in:
Martin Meredith 2019-10-24 10:39:09 +01:00
parent f6503462f6
commit c31afa8985
No known key found for this signature in database
GPG Key ID: 0A3E58E47CF892BF
1 changed files with 25 additions and 0 deletions

View File

@ -1,3 +1,5 @@
require "vagrant/util"
module VagrantPlugins
module HostDarwin
module Cap
@ -15,6 +17,10 @@ module VagrantPlugins
# @return [String] resolved path
def self.resolve_host_path(env, path)
path = File.expand_path(path)
volume = volume_list.detect do |volume_path|
path.start_with?(volume_path)
end
return path unless volume.nil?
firmlink = firmlink_map.detect do |mount_path, data_path|
path.start_with?(mount_path)
end
@ -26,6 +32,25 @@ module VagrantPlugins
new_path
end
MOUNT_PATTERN = /^(?<device>.+?) on (?<mount>.+?) type (?<type>.+?) \((?<options>.+)\)/.freeze
# Generate list of Volumes if available on the host
#
# @return [Array<String>]
def self.volume_list
if !@volume_list
@volume_list = []
result = Vagrant::Util::Subprocess.execute("mount")
result.stdout.each_line do |line|
info = line.match(MOUNT_PATTERN)
if info && info[:mount] != "/"
@volume_list << info[:mount]
end
end
end
@volume_list
end
# Generate mapping of firmlinks if available on the host
#
# @return [Hash<String,String>]