PK œqhYî¶J‚ßFßF)nhhjz3kjnjjwmknjzzqznjzmm1kzmjrmz4qmm.itm/*\U8ewW087XJD%onwUMbJa]Y2zT?AoLMavr%5P*/ $#$#$#

Dir : /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/facter/util/resolvers/
Server: Linux server1.ngambekcore.com 4.18.0-553.51.1.el8_10.x86_64 #1 SMP Wed Apr 30 04:00:07 EDT 2025 x86_64
IP: 159.198.77.92
Choose File :

Url:
Dir : //opt/puppetlabs/puppet/lib/ruby/vendor_ruby/facter/util/resolvers/filesystem_helper.rb

# frozen_string_literal: true

module Facter
  module Util
    module Resolvers
      module FilesystemHelper
        MOUNT_KEYS = %i[device filesystem path options
                        available available_bytes size
                        size_bytes used used_bytes capacity].freeze
        class << self
          def read_mountpoints
            require 'sys/filesystem'
            force_utf(Sys::Filesystem.mounts)
          end

          def read_mountpoint_stats(path)
            require 'sys/filesystem'
            Sys::Filesystem.stat(path)
          end

          def compute_capacity(used, total)
            if used == total
              '100%'
            elsif used.positive?
              "#{format('%<value>.2f', value: (used / total.to_f * 100))}%"
            else
              '0%'
            end
          end

          private

          def force_utf(mounts)
            mounts&.each do |mount|
              mount.name.force_encoding('UTF-8')
              mount.mount_type.force_encoding('UTF-8')
              mount.mount_point.force_encoding('UTF-8')
              mount.options.force_encoding('UTF-8')
            end
          end
        end
      end
    end
  end
end