core: support "mount_options" for arbitrary mount options [GH-1029]

This commit is contained in:
Mitchell Hashimoto 2013-09-01 12:25:21 -07:00
parent 2d2180e5a5
commit e5b35d1c83
7 changed files with 29 additions and 4 deletions

View File

@ -8,6 +8,9 @@ BACKWARDS INCOMPATIBILITY:
- `config.vm.graceful_halt_retry_*` settings are gone. Instead, a single
timeout is now used to wait for a graceful halt to work, specified
by `config.vm.graceful_halt_timeout`.
- The ':extra' flag to shared folders for specifying arbitrary mount
options has been replaced with the `:mount_options` flag, which is now
an array of mount options.
FEATURES:

View File

@ -18,8 +18,14 @@ module VagrantPlugins
# Mount
hostpath = opts[:hostpath].dup
hostpath.gsub!("'", "'\\\\''")
mount_command = "mount -o udp,vers=#{opts[:nfs_version]} #{ip}:'#{hostpath}' #{expanded_guest_path}"
# Figure out any options
mount_opts = ["vers=#{opts[:nfs_version]}", "udp"]
if opts[:mount_options]
mount_opts = opts[:mount_options].dup
end
mount_command = "mount -o '#{mount_opts.join(",")}' #{ip}:'#{hostpath}' #{expanded_guest_path}"
retryable(:on => Vagrant::Errors::LinuxNFSMountFailed, :tries => 5, :sleep => 2) do
machine.communicate.sudo(mount_command,
:error_class => Vagrant::Errors::LinuxNFSMountFailed)

View File

@ -8,7 +8,10 @@ module VagrantPlugins
# Determine the permission string to attach to the mount command
mount_options = "-o uid=`id -u #{options[:owner]}`,gid=`getent group #{options[:group]} | cut -d: -f3`"
mount_options += ",#{options[:extra]}" if options[:extra]
if options[:mount_options]
mount_options += ",#{options[:mount_options].join(",")}"
end
mount_command = "mount -t vboxsf #{mount_options} #{name} #{expanded_guest_path}"
# Create the guest path if it doesn't exist

View File

@ -16,7 +16,10 @@ module VagrantPlugins
# Mount the folder with the proper owner/group
mount_options = "-o uid=`#{id_cmd} -u #{owner}`,gid=`#{id_cmd} -g #{group}`"
mount_options += ",#{options[:extra]}" if options[:extra]
if options[:mount_options]
mount_options += ",#{options[:mount_options].join(",")}"
end
machine.communicate.execute("#{machine.config.solaris.suexec_cmd} /sbin/mount -F vboxfs #{mount_options} #{name} #{guestpath}")
# chown the folder to the proper owner/group

View File

@ -20,7 +20,10 @@ module VagrantPlugins
# Mount the folder with the proper owner/group
mount_options = "-o uid=`#{id_cmd} -u #{owner}`,gid=`#{id_cmd} -g #{group}`"
mount_options += ",#{options[:extra]}" if options[:extra]
if options[:mount_options]
mount_options += ",#{options[:mount_options].join(",")}"
end
machine.communicate.execute("#{machine.config.solaris11.suexec_cmd} /sbin/mount -F vboxfs #{mount_options} #{name} #{guestpath}")
# chown the folder to the proper owner/group

View File

@ -379,6 +379,10 @@ module VagrantPlugins
:path => options[:hostpath])
end
end
if options[:mount_options] && !options[:mount_options].is_a?(Array)
errors << I18n.t("vagrant.config.vm.shared_folder_mount_options_array")
end
end
if has_nfs

View File

@ -719,6 +719,9 @@ en:
shared_folder_nfs_owner_group: |-
Shared folder that have NFS enabled do no support owner/group
attributes. Host path: %{path}
shared_folder_mount_options_array: |-
Shared folder mount options specified by 'mount_options' must
be an array of options.
#-------------------------------------------------------------------------------
# Translations for commands. e.g. `vagrant x`