diff options
Diffstat (limited to 'lib/chef/provider/mount/linux.rb')
-rw-r--r-- | lib/chef/provider/mount/linux.rb | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/lib/chef/provider/mount/linux.rb b/lib/chef/provider/mount/linux.rb index 382e37d41a..83fbfab957 100644 --- a/lib/chef/provider/mount/linux.rb +++ b/lib/chef/provider/mount/linux.rb @@ -29,10 +29,16 @@ class Chef # "findmnt" outputs the mount points with volume. # Convert the mount_point of the resource to a real path in case it # contains symlinks in its parents dirs. + def loop_mount_points + # get loop_mount_points only if not initialized earlier + @loop_mount_points ||= shell_out!("losetup -a").stdout + + rescue Errno::ENOENT + @loop_mount_points = "" + end def mounted? mounted = false - real_mount_point = if ::File.exists? @new_resource.mount_point ::File.realpath(@new_resource.mount_point) else @@ -45,6 +51,14 @@ class Chef when /\A#{Regexp.escape(real_mount_point)}\s+#{device_mount_regex}\s/ mounted = true logger.trace("Special device #{device_logstring} mounted as #{real_mount_point}") + # Permalink for loop type devices mount points https://rubular.com/r/a0bS4p2RvXsGxx + when %r{\A#{Regexp.escape(real_mount_point)}\s+\/dev\/loop+[0-9]+\s} + loop_mount_points.each_line do |mount_point| + if mount_point.include? device_real + mounted = true + break + end + end # Permalink for multiple devices mounted to the same mount point(i.e. '/proc') https://rubular.com/r/a356yzspU7N9TY when %r{\A#{Regexp.escape(real_mount_point)}\s+([/\w])+\s} mounted = false @@ -64,4 +78,4 @@ class Chef end end end -end +end
\ No newline at end of file |