diff --git a/lib/facter/mounts.rb b/lib/facter/mounts.rb index e8c83bb..572b5e2 100644 --- a/lib/facter/mounts.rb +++ b/lib/facter/mounts.rb @@ -1,54 +1,59 @@ -# from https://anonscm.debian.org/git/mirror/dsa-puppet.git/tree/modules/debian-org/lib/facter/mounts.rb - begin - require 'filesystem' - Facter.add("mounts") do ignorefs = [ "NFS", "afs", "autofs", "binfmt_misc", "cgroup", "cifs", "coda", "debugfs", "devfs", "devpts", "devtmpfs", + "efivarfs", "ftpfs", + "fuse", + "fuse.gvfsd-fuse", + "fuse.lxcfs", "fuse.snapshotfs", "fusectl", "hugetlbfs", "iso9660", "lustre_lite", "mfs", "mqueue", "ncpfs", "nfs", "nfs4", "nfsd", "proc", "pstore", "rpc_pipefs", "securityfs", "shfs", "smbfs", "sysfs", "tmpfs", "udf", "usbfs", - ] + ].uniq.sort.join(',') + mountpoints = [] - FileSystem.mounts.each do |m| - if ((not ignorefs.include?(m.fstype)) && (m.options !~ /bind/)) - mountpoints << m.mount - end + + Facter::Util::Resolution.exec("findmnt --list --noheadings -o TARGET,SOURCE --invert --types #{ignorefs}").lines.each do |line| + mountpoint, source = line.chomp.split + # bind mounts + if not source.end_with?(']') + mountpoints << mountpoint + end end + setcode do - mountpoints.uniq.sort.join(',') + mountpoints end - end + end rescue Exception => _ end