Class: Resilience::ObjectTable

Inherits:
Object
  • Object
show all
Includes:
OnImage
Defined in:
lib/resilience/tables/object.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from OnImage

#image, image, included, restore_pos, #restore_pos, store_pos, #store_pos

Constructor Details

#initializeObjectTable

Returns a new instance of ObjectTable.



11
12
13
# File 'lib/resilience/tables/object.rb', line 11

def initialize
  @pages ||= {}
end

Instance Attribute Details

#pagesObject

Returns the value of attribute pages.



9
10
11
# File 'lib/resilience/tables/object.rb', line 9

def pages
  @pages
end

Class Method Details

.parseObject



15
16
17
18
19
# File 'lib/resilience/tables/object.rb', line 15

def self.parse
  table = new
  table.parse_pages
  table
end

Instance Method Details

#object_page_idObject

Depends on SystemTable extraction



22
23
24
25
26
27
# File 'lib/resilience/tables/object.rb', line 22

def object_page_id
  # in the images I've seen this has always been the first entry
  # in the system table, though always has virtual page id = 2
  # which we could look for if this turns out not to be the case
  image.system_table.pages.first
end

#parse_pagesObject



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/resilience/tables/object.rb', line 29

def parse_pages
  object_page_address = object_page_id * PAGE_SIZE

  # read number of objects from index header
  image.seek(object_page_address + ADDRESSES[:first_attr])
  first_attr  = Attribute.read
  num_objects = first_attr.unpack('L*')[ADDRESSES[:num_objects]/4]

  # start of table attr, skip for now
  Attribute.read

  0.upto(num_objects-1) do
    object_record     = FSDir::Record.read
    object_id         = object_record.key.unpack('C*')

    # here object page is first qword of record value
    object_page       = object_record.value.unpack('Q*').first
    @pages[object_id] = object_page
  end
end