Skip to content

Commit

Permalink
ignoring trailing slash in network fs_specs
Browse files Browse the repository at this point in the history
  • Loading branch information
llaurent authored and btm committed Apr 30, 2012
1 parent 0a4f57e commit 84d58f7
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions chef/lib/chef/provider/mount/mount.rb
Expand Up @@ -172,8 +172,13 @@ def disable_fs
end
end

def network_device?
@new_resource.device =~ /:/ || @new_resource.device =~ /\/\//
end

def device_should_exist?
@new_resource.device !~ /:/ && @new_resource.device !~ /\/\// && @new_resource.fstype != "tmpfs" && @new_resource.fstype != 'fuse'
( not network_device? ) &&
( not %w[ tmpfs fuse ].include? @new_resource.fstype )
end

private
Expand Down Expand Up @@ -216,7 +221,14 @@ def device_logstring
end

def device_mount_regex
::File.symlink?(device_real) ? "(?:#{Regexp.escape(device_real)})|(?:#{Regexp.escape(::File.readlink(device_real))})" : Regexp.escape(device_real)
if network_device?
# ignore trailing slash
Regexp.escape(device_real)+"/?"
elsif ::File.symlink?(device_real)
"(?:#{Regexp.escape(device_real)})|(?:#{Regexp.escape(::File.readlink(device_real))})"
else
Regexp.escape(device_real)
end
end

def device_fstab_regex
Expand Down

0 comments on commit 84d58f7

Please sign in to comment.