Sha256: 0fd3b765798f3024d1306f8b51800722884e0b2b0efbbfca8a5496c66e9ab924

Contents?: true

Size: 1.7 KB

Versions: 52

Compression:

Stored size: 1.7 KB

Contents

module FsProbe
  MODDIR = File.expand_path(File.join(File.dirname(__FILE__), "modules"))

  PROBE_FILES = Dir.glob(File.join(MODDIR, "*Probe.rb*"))
  PROBE_FILES.each do |p|
    p.slice!(0..MODDIR.length)
    p.chomp!(".enc")
    p.chomp!(".rb")
  end
  # Reorder known probes for optimization
  PROBE_FILES.unshift("Fat32Probe")    if PROBE_FILES.delete("Fat32Probe")
  PROBE_FILES.unshift("Reiser4Probe")  if PROBE_FILES.delete("Reiser4Probe")
  PROBE_FILES.unshift("ReiserFSProbe") if PROBE_FILES.delete("ReiserFSProbe")
  PROBE_FILES.unshift("Ext4Probe")     if PROBE_FILES.delete("Ext4Probe")
  PROBE_FILES.unshift("Ext3Probe")     if PROBE_FILES.delete("Ext3Probe")
  PROBE_FILES.unshift("NTFSProbe")     if PROBE_FILES.delete("NTFSProbe")
  PROBE_FILES.unshift("XFSProbe")      if PROBE_FILES.delete("XFSProbe")

  def self.getFsMod(dobj, probes = nil)
    probes = PROBE_FILES if probes.nil?
    probes = [probes] unless probes.kind_of?(Array)

    fname = dobj.dInfo.fileName || "" rescue ""
    fname = dobj.dInfo.lvObj.lvName || "" if fname.empty? rescue ""
    partNum = dobj.partNum

    probes.each do |pmod|
      $log.debug("MIQ(FsProbe-getFsMod) FS probe attempting [#{pmod}] for [#{fname}] [partition: #{partNum}]")

      require_relative "modules/#{pmod}"
      begin
        if Object.const_get(pmod).probe(dobj)
          mod = pmod.chomp("Probe")
          $log.info("MIQ(FsProbe-getFsMod) FS probe detected [#{mod}] for [#{fname}] [partition: #{partNum}]")
          require_relative "modules/#{mod}"
          return Object.const_get(mod)
        end
      rescue StandardError => err
        $log.debug(err.to_s)
        # continue to probe even when one probing fails.
        next
      end
    end
    nil
  end
end

Version data entries

52 entries across 52 versions & 1 rubygems

Version Path
manageiq-smartstate-0.10.1 lib/fs/MiqFS/FsProbe.rb
manageiq-smartstate-0.10.0 lib/fs/MiqFS/FsProbe.rb
manageiq-smartstate-0.9.0 lib/fs/MiqFS/FsProbe.rb
manageiq-smartstate-0.8.1 lib/fs/MiqFS/FsProbe.rb
manageiq-smartstate-0.8.0 lib/fs/MiqFS/FsProbe.rb
manageiq-smartstate-0.7.0 lib/fs/MiqFS/FsProbe.rb
manageiq-smartstate-0.6.2 lib/fs/MiqFS/FsProbe.rb
manageiq-smartstate-0.5.10 lib/fs/MiqFS/FsProbe.rb
manageiq-smartstate-0.3.10 lib/fs/MiqFS/FsProbe.rb
manageiq-smartstate-0.6.1 lib/fs/MiqFS/FsProbe.rb
manageiq-smartstate-0.3.9 lib/fs/MiqFS/FsProbe.rb
manageiq-smartstate-0.6.0 lib/fs/MiqFS/FsProbe.rb
manageiq-smartstate-0.5.9 lib/fs/MiqFS/FsProbe.rb
manageiq-smartstate-0.5.8 lib/fs/MiqFS/FsProbe.rb
manageiq-smartstate-0.3.8 lib/fs/MiqFS/FsProbe.rb
manageiq-smartstate-0.5.7 lib/fs/MiqFS/FsProbe.rb
manageiq-smartstate-0.3.7 lib/fs/MiqFS/FsProbe.rb
manageiq-smartstate-0.5.6 lib/fs/MiqFS/FsProbe.rb
manageiq-smartstate-0.3.6 lib/fs/MiqFS/FsProbe.rb
manageiq-smartstate-0.5.5 lib/fs/MiqFS/FsProbe.rb