diff --git a/CHANGELOG.md b/CHANGELOG.md index 84c49c3..34c2201 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ All notable changes to this project will be documented in this file. ## Unreleased +- Support use of symlinks for device paths + ## 4.0.14 - *2024-05-03* - Update tested platforms diff --git a/libraries/fs.rb b/libraries/fs.rb index 9b59097..926a84c 100644 --- a/libraries/fs.rb +++ b/libraries/fs.rb @@ -11,7 +11,18 @@ module FilesystemMod # Check to determine if the device is mounted. def mounted?(device) - shell_out("grep -q '#{device}' /proc/mounts").exitstatus != 0 ? nil : shell_out("grep -q '#{device}' /proc/mounts").exitstatus + device_path = device + unless File.exist?(device) + # Returning nil on missing file because it sure isn't mounted. + return + end + + # If the device is a symlink the real path is obtained so the check on /proc/mounts is valid. + if File.symlink?(device) + device_path = File.realpath(device) + end + + shell_out("grep -q '#{device_path}' /proc/mounts").exitstatus != 0 ? nil : shell_out("grep -q '#{device_path}' /proc/mounts").exitstatus end # Check to determine if the mount is frozen.