Skip to content

Commit

Permalink
sshfs_forward_mount: exit check if dst path missing
Browse files Browse the repository at this point in the history
`readlink -f` can throw an error if a path doesn't exist in the guest.
We will simply check to see if the path actually exists before trying to
find the absolute path of it.
  • Loading branch information
dustymabe committed Nov 13, 2016
1 parent a7d8a89 commit b3eae35
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lib/vagrant-sshfs/cap/guest/linux/sshfs_forward_mount.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,19 @@ class MountSSHFS

def self.sshfs_forward_is_folder_mounted(machine, opts)
mounted = false
guest_path = opts[:guestpath]

# If the path doesn't exist at all in the machine then we
# can safely say it is not mounted
exists = machine.communicate.test("test -e #{guest_path}")
return false unless exists

# find the absolute path so that we can properly check if it is mounted
# https://github.com/dustymabe/vagrant-sshfs/issues/44
absolute_guest_path = machine.guest.capability(
:sshfs_get_absolute_path, opts[:guestpath])
:sshfs_get_absolute_path, guest_path)

# consult /proc/mounts to see if it is mounted or not
machine.communicate.execute("cat /proc/mounts") do |type, data|
if type == :stdout
data.each_line do |line|
Expand Down

0 comments on commit b3eae35

Please sign in to comment.