Sha256: 373ac03f043cd4e2dc93d7cdb6d10fb5ae423b494ffea18114729c0d0fb15d7d

Contents?: true

Size: 1.37 KB

Versions: 67

Compression:

Stored size: 1.37 KB

Contents

# encoding: US-ASCII

module NTFS
  module Utils
    # Make a reference (upper two bytes are seq num, lower six are entry).
    def self.MkRef(ref)
      ref.divmod(2**48)
    end

    def self.gotBit?(flags, bit)
      (flags & bit) == bit
    end

    # Process per-sector "fixups" that NTFS uses to detect corruption of
    # multi-sector data structures, like MFT records.
    def self.process_fixups(buf, fixup_offset, usa_offset, usa_count)
      #
      # The signature value we must look for is stored just before the fix-up array.
      #
      fu_sig = buf[usa_offset, 2].unpack('S')[0]

      #
      # For each end-of-sector, check that the last two bytes equal the fixup signature.
      # If so, replace them with original data stored in the update sequence array.
      #
      1.upto(usa_count - 1) do |i|
        sig = buf[i * fixup_offset - 2, 2].unpack('S')[0]
        raise "NTFS Fixup Error: fixup signature:<#{fu_sig}> does not match signature[#{i}]=<#{sig}> - consider running chkdsk" if sig != fu_sig
        buf[i * fixup_offset - 2, 2] = buf[i * 2 + usa_offset, 2]
      end

      buf
    end

    def self.validate_signature(signature, expected)
      if signature != expected
        raise "Uninitialized"   if signature == "\000\000\000\000"
        raise "Bad Sector"      if signature == 'BAAD'
        raise "Invalid Signature <#{signature}>"
      end
    end
  end
end

Version data entries

67 entries across 67 versions & 1 rubygems

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