The full options data is sent to mount_shared_folder

This commit is contained in:
Mitchell Hashimoto 2012-01-11 23:14:04 -08:00
parent 8a17c350ca
commit 14d61f61ba
4 changed files with 20 additions and 11 deletions

View File

@ -91,12 +91,15 @@ module Vagrant
:name => name, :name => name,
:guest_path => data[:guestpath])) :guest_path => data[:guestpath]))
# Dup the data so we can pass it to the guest API
data = data.dup
# Calculate the owner and group # Calculate the owner and group
owner = data[:owner] || @env[:vm].config.ssh.username data[:owner] ||= @env[:vm].config.ssh.username
group = data[:group] || @env[:vm].config.ssh.username data[:group] ||= @env[:vm].config.ssh.username
# Mount the actual folder # Mount the actual folder
@env[:vm].guest.mount_shared_folder(name, data[:guestpath], owner, group) @env[:vm].guest.mount_shared_folder(name, data[:guestpath], data)
else else
# If no guest path is specified, then automounting is disabled # If no guest path is specified, then automounting is disabled
@env[:ui].info(I18n.t("vagrant.actions.vm.share_folders.nomount_entry", @env[:ui].info(I18n.t("vagrant.actions.vm.share_folders.nomount_entry",

View File

@ -61,7 +61,9 @@ module Vagrant
# @param [String] name The name of the shared folder. # @param [String] name The name of the shared folder.
# @param [String] guestpath The path on the machine which the user # @param [String] guestpath The path on the machine which the user
# wants the folder mounted. # wants the folder mounted.
def mount_shared_folder(name, guestpath, owner, group) # @param [Hash] options Additional options for the shared folder
# which can be honored.
def mount_shared_folder(name, guestpath, options)
raise BaseError, :_key => :unsupported_shared_folder raise BaseError, :_key => :unsupported_shared_folder
end end

View File

@ -34,10 +34,10 @@ module Vagrant
end end
end end
def mount_shared_folder(name, guestpath, owner, group) def mount_shared_folder(name, guestpath, options)
@vm.channel.sudo("mkdir -p #{guestpath}") @vm.channel.sudo("mkdir -p #{guestpath}")
mount_folder(name, guestpath, owner, group) mount_folder(name, guestpath, options)
@vm.channel.sudo("chown `id -u #{owner}`:`id -g #{group}` #{guestpath}") @vm.channel.sudo("chown `id -u #{options[:owner]}`:`id -g #{options[:group]}` #{guestpath}")
end end
def mount_nfs(ip, folders) def mount_nfs(ip, folders)
@ -54,9 +54,9 @@ module Vagrant
#------------------------------------------------------------------- #-------------------------------------------------------------------
# "Private" methods which assist above methods # "Private" methods which assist above methods
#------------------------------------------------------------------- #-------------------------------------------------------------------
def mount_folder(name, guestpath, owner, group, sleeptime=5) def mount_folder(name, guestpath, options)
# Determine the permission string to attach to the mount command # Determine the permission string to attach to the mount command
options = "-o uid=`id -u #{owner}`,gid=`id -g #{group}`" options = "-o uid=`id -u #{options[:owner]}`,gid=`id -g #{options[:group]}`"
attempts = 0 attempts = 0
while true while true
@ -69,7 +69,7 @@ module Vagrant
attempts += 1 attempts += 1
raise LinuxError, :mount_fail if attempts >= 10 raise LinuxError, :mount_fail if attempts >= 10
sleep sleeptime sleep 5
end end
end end
end end

View File

@ -90,7 +90,11 @@ module Vagrant
end # while end # while
end end
def mount_shared_folder(name, guestpath, owner, group) def mount_shared_folder(name, guestpath, options)
# These are just far easier to use than the full options syntax
owner = options[:owner]
group = options[:group]
# Create the shared folder # Create the shared folder
vm.channel.execute("#{vm.config.solaris.suexec_cmd} mkdir -p #{guestpath}") vm.channel.execute("#{vm.config.solaris.suexec_cmd} mkdir -p #{guestpath}")