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.2.18 lib/fs/MiqFS/modules/Fat32Probe.rb
manageiq-smartstate-0.2.17 lib/fs/MiqFS/modules/Fat32Probe.rb
manageiq-smartstate-0.2.16 lib/fs/MiqFS/modules/Fat32Probe.rb
manageiq-smartstate-0.2.15 lib/fs/MiqFS/modules/Fat32Probe.rb
manageiq-smartstate-0.2.14 lib/fs/MiqFS/modules/Fat32Probe.rb
manageiq-smartstate-0.2.13 lib/fs/MiqFS/modules/Fat32Probe.rb
manageiq-smartstate-0.2.12 lib/fs/MiqFS/modules/Fat32Probe.rb
manageiq-smartstate-0.2.11 lib/fs/MiqFS/modules/Fat32Probe.rb
manageiq-smartstate-0.2.10 lib/fs/MiqFS/modules/Fat32Probe.rb
manageiq-smartstate-0.2.9 lib/fs/MiqFS/modules/Fat32Probe.rb
manageiq-smartstate-0.2.8 lib/fs/MiqFS/modules/Fat32Probe.rb
manageiq-smartstate-0.2.7 lib/fs/MiqFS/modules/Fat32Probe.rb