Sha256: fcd385cec384a63247bb70d8580699bbe478f6010db3557d1b35c69d8f80b4e8

Contents?: true

Size: 986 Bytes

Versions: 52

Compression:

Stored size: 986 Bytes

Contents

module Fat32Probe
  def self.probe(dobj)
    unless dobj.kind_of?(MiqDisk)
      $log&.debug "Fat32Probe << FALSE because Disk Object class is not MiqDisk, but is '#{dobj.class}'"
      return false
    end

    # Assume FAT32 - read boot sector.
    dobj.seek(0)
    bs = dobj.read(512)

    # Check byte 66 for 0x29 (extended signature).
    if bs.nil? || bs[66] != 0x29
      $log&.debug("Fat32Probe << FALSE because there is no extended signature")
      return false
    end

    # Check file system label for 'FAT32   '
    # NOTE: This works for MS tools but maybe not for others.
    if bs.length < 90
      $log&.debug("Fat32Probe << FALSE because there is no filesystem label")
      return false
    end

    fslabel = bs[82, 8].unpack('a8')[0].strip
    fat32 = fslabel == 'FAT32'
    if $log
      $log.debug("Fat32Probe << TRUE") if fat32
      $log.debug("Fat32Probe << FALSE because FS label is NOT FAT32, but is '#{fslabel}'") unless fat32
    end

    fat32
  end
end

Version data entries

52 entries across 52 versions & 1 rubygems

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