Class: Resilience::GPT

Inherits:
BootTable show all
Defined in:
lib/resilience/tables/boot.rb

Overview

class MBR

Constant Summary collapse

NUM_ADDRESS =
0x50
PARTITIONS_START =

from the current image offset, the start of gpt partition

0x200
PARTITION_SIZE =
0x80
OFFSET_ADDRESS =
0x20
SIG =

EFI PART

[0x45, 0x46, 0x49, 0x20, 0x50, 0x41, 0x52, 0x54]

Constants inherited from BootTable

BootTable::SECTOR_SIZE

Instance Method Summary collapse

Methods inherited from BootTable

#refs_offset, #refs_offsets

Methods included from OnImage

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

Instance Method Details

#fs_offsetsObject



77
78
79
80
81
82
83
84
85
86
87
# File 'lib/resilience/tables/boot.rb', line 77

def fs_offsets
  offsets = []
  0.upto(num-1) do |i|
    image.seek PARTITIONS_START + i * PARTITION_SIZE
    partition = image.read(PARTITION_SIZE).unpack('C*')
    offset    = partition[OFFSET_ADDRESS...OFFSET_ADDRESS+8].pack('C*').unpack('V').first
    offsets << offset * SECTOR_SIZE
    break if offset == 0
  end
  offsets
end

#numObject



72
73
74
75
# File 'lib/resilience/tables/boot.rb', line 72

def num
  image.seek NUM_ADDRESS
  image.read(4).unpack('V').first
end