core: support "mount_options" for arbitrary mount options [GH-1029]
This commit is contained in:
parent
2d2180e5a5
commit
e5b35d1c83
|
@ -8,6 +8,9 @@ BACKWARDS INCOMPATIBILITY:
|
||||||
- `config.vm.graceful_halt_retry_*` settings are gone. Instead, a single
|
- `config.vm.graceful_halt_retry_*` settings are gone. Instead, a single
|
||||||
timeout is now used to wait for a graceful halt to work, specified
|
timeout is now used to wait for a graceful halt to work, specified
|
||||||
by `config.vm.graceful_halt_timeout`.
|
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:
|
FEATURES:
|
||||||
|
|
||||||
|
|
|
@ -18,8 +18,14 @@ module VagrantPlugins
|
||||||
# Mount
|
# Mount
|
||||||
hostpath = opts[:hostpath].dup
|
hostpath = opts[:hostpath].dup
|
||||||
hostpath.gsub!("'", "'\\\\''")
|
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
|
retryable(:on => Vagrant::Errors::LinuxNFSMountFailed, :tries => 5, :sleep => 2) do
|
||||||
machine.communicate.sudo(mount_command,
|
machine.communicate.sudo(mount_command,
|
||||||
:error_class => Vagrant::Errors::LinuxNFSMountFailed)
|
:error_class => Vagrant::Errors::LinuxNFSMountFailed)
|
||||||
|
|
|
@ -8,7 +8,10 @@ module VagrantPlugins
|
||||||
|
|
||||||
# Determine the permission string to attach to the mount command
|
# 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 = "-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}"
|
mount_command = "mount -t vboxsf #{mount_options} #{name} #{expanded_guest_path}"
|
||||||
|
|
||||||
# Create the guest path if it doesn't exist
|
# Create the guest path if it doesn't exist
|
||||||
|
|
|
@ -16,7 +16,10 @@ module VagrantPlugins
|
||||||
|
|
||||||
# Mount the folder with the proper owner/group
|
# Mount the folder with the proper owner/group
|
||||||
mount_options = "-o uid=`#{id_cmd} -u #{owner}`,gid=`#{id_cmd} -g #{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}")
|
machine.communicate.execute("#{machine.config.solaris.suexec_cmd} /sbin/mount -F vboxfs #{mount_options} #{name} #{guestpath}")
|
||||||
|
|
||||||
# chown the folder to the proper owner/group
|
# chown the folder to the proper owner/group
|
||||||
|
|
|
@ -20,7 +20,10 @@ module VagrantPlugins
|
||||||
|
|
||||||
# Mount the folder with the proper owner/group
|
# Mount the folder with the proper owner/group
|
||||||
mount_options = "-o uid=`#{id_cmd} -u #{owner}`,gid=`#{id_cmd} -g #{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}")
|
machine.communicate.execute("#{machine.config.solaris11.suexec_cmd} /sbin/mount -F vboxfs #{mount_options} #{name} #{guestpath}")
|
||||||
|
|
||||||
# chown the folder to the proper owner/group
|
# chown the folder to the proper owner/group
|
||||||
|
|
|
@ -379,6 +379,10 @@ module VagrantPlugins
|
||||||
:path => options[:hostpath])
|
:path => options[:hostpath])
|
||||||
end
|
end
|
||||||
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
|
end
|
||||||
|
|
||||||
if has_nfs
|
if has_nfs
|
||||||
|
|
|
@ -719,6 +719,9 @@ en:
|
||||||
shared_folder_nfs_owner_group: |-
|
shared_folder_nfs_owner_group: |-
|
||||||
Shared folder that have NFS enabled do no support owner/group
|
Shared folder that have NFS enabled do no support owner/group
|
||||||
attributes. Host path: %{path}
|
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`
|
# Translations for commands. e.g. `vagrant x`
|
||||||
|
|
Loading…
Reference in New Issue