class VagrantPlugins::GuestCygwin::Cap::MountSSHFS

Public Class Methods

is_cygwin(machine, opts) click to toggle source
# File lib/vagrant-sshfs/cap/guest/cygwin/sshfs_forward_mount.rb, line 8
def self.is_cygwin(machine, opts)
  return true
end
sshfs_forward_get_umount_cmd(expanded_guest_path) click to toggle source
# File lib/vagrant-sshfs/cap/guest/cygwin/sshfs_forward_mount.rb, line 12
def self.sshfs_forward_get_umount_cmd(expanded_guest_path)
  # sshfs-win mount is not seen as mount by cygwin,
  # so we cannot unmount it using umount,
  # we need to kill sshfs process ( which causes umount )

  cmd = 'sh -c "'
  # iterate over cmdlines of all cygwin processes
  cmd += 'for cmdline in /proc/*/cmdline ; do'
  # if command starts with sshfs
  cmd += ' if strings -n 1 \\"\\${cmdline}\\" | head -n 1 | grep -q \'^sshfs\\$\''
  # and contains #{expanded_guest_path}
  cmd += " && strings -n 1 \\\"\\${cmdline}\\\" | grep -q '^#{expanded_guest_path}\\$' ;"
  cmd += ' then'
  # get pid from proc path
  cmd += ' pid=\\"\\$( basename \\"\\$( dirname \\"\\${cmdline}\\" )\\" )\\" ;'
  cmd += ' printf \'Syncing cached writes ...\\\\n\' ;'
  # synchronize casched writes to filesystems (just in case)
  cmd += ' sync ;'
  cmd += ' printf \'Killing sshfs process: %s ...\\\\n\' \\"\\${pid}\\" ;'
  # kill sshfs process
  cmd += ' kill \\"\\${pid}\\" ;'
  # break the loop
  cmd += ' break ;'
  cmd += ' fi'
  cmd += ' done'
  cmd += '"'

  return cmd
end