Class: NTFS::IndexRecordHeader
- Inherits:
-
Object
- Object
- NTFS::IndexRecordHeader
- Defined in:
- lib/fs/ntfs/index_record_header.rb
Constant Summary collapse
- EXPECTED_SIGNATURE =
'INDX'
Instance Attribute Summary collapse
-
#data ⇒ Object
Returns the value of attribute data.
-
#signature ⇒ Object
readonly
Returns the value of attribute signature.
-
#valid ⇒ Object
readonly
Returns the value of attribute valid.
-
#vcn ⇒ Object
readonly
Returns the value of attribute vcn.
Class Method Summary collapse
Instance Method Summary collapse
- #dump(withData = nil) ⇒ Object
-
#initialize(buf, bps) ⇒ IndexRecordHeader
constructor
A new instance of IndexRecordHeader.
- #isValid? ⇒ Boolean
- #to_s ⇒ Object
Constructor Details
#initialize(buf, bps) ⇒ IndexRecordHeader
Returns a new instance of IndexRecordHeader.
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/fs/ntfs/index_record_header.rb', line 37 def initialize(buf, bps) log_prefix = "MIQ(NTFS::IndexRecordHeader.initialize)" raise "#{log_prefix} Nil buffer" if buf.nil? raise "#{log_prefix} Nil bytes per sector" if bps.nil? buf = buf.read(buf.length) if buf.kind_of?(DataRun) @data = buf @bps = bps # Decode the index record header structure. @irh = INDEX_RECORD_HEADER.decode(buf) @signature = @irh['signature'] @vcn = @irh['index_block_vcn'] @valid = true begin # Check for proper signature. NTFS::Utils.validate_signature(@irh['signature'], EXPECTED_SIGNATURE) # Process per-sector "fixups" that NTFS uses to detect corruption of multi-sector data structures @data = NTFS::Utils.process_fixups(@data, @bps, @irh['usa_offset'], @irh['usa_count']) rescue => err @valid = false $log.error("#{log_prefix} Invalid Index Record Header because: <#{err.}>\n#{dump}") end end |
Instance Attribute Details
#data ⇒ Object
Returns the value of attribute data.
31 32 33 |
# File 'lib/fs/ntfs/index_record_header.rb', line 31 def data @data end |
#signature ⇒ Object (readonly)
Returns the value of attribute signature.
30 31 32 |
# File 'lib/fs/ntfs/index_record_header.rb', line 30 def signature @signature end |
#valid ⇒ Object (readonly)
Returns the value of attribute valid.
30 31 32 |
# File 'lib/fs/ntfs/index_record_header.rb', line 30 def valid @valid end |
#vcn ⇒ Object (readonly)
Returns the value of attribute vcn.
30 31 32 |
# File 'lib/fs/ntfs/index_record_header.rb', line 30 def vcn @vcn end |
Class Method Details
.size ⇒ Object
33 34 35 |
# File 'lib/fs/ntfs/index_record_header.rb', line 33 def self.size SIZEOF_INDEX_RECORD_HEADER end |
Instance Method Details
#dump(withData = nil) ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/fs/ntfs/index_record_header.rb', line 71 def dump(withData = nil) out = "\#<#{self.class}:0x#{'%08x' % object_id}>\n" out << " Signature : #{@irh['signature']}\n" out << " USA Offset : #{@irh['usa_offset']}\n" out << " USA Count : #{@irh['usa_count']}\n" out << " $LogFile sequence number : #{@irh['lsn']}\n" out << " Index Block VCN : #{@irh['index_block_vcn']}\n" if withData out << "Raw Data:\n" out << @data.hex_dump end out << "---\n" end |
#isValid? ⇒ Boolean
63 64 65 |
# File 'lib/fs/ntfs/index_record_header.rb', line 63 def isValid? @valid end |
#to_s ⇒ Object
67 68 69 |
# File 'lib/fs/ntfs/index_record_header.rb', line 67 def to_s @irh['signature'] end |