Class: VirtDisk::Partition

Inherits:
ClientHead show all
Defined in:
lib/virt_disk/partition.rb

Constant Summary collapse

MBR_SIZE =
512
DOS_SIG =
"55aa"
GPT_SIG =
238
DOS_PARTITION_ENTRY =
BinaryStruct.new([
  'C', :bootable,
  'C', :startCHS0,
  'C', :startCHS1,
  'C', :startCHS2,
  'C', :ptype,
  'C', :endCHS0,
  'C', :endCHS1,
  'C', :endCHS1,
  'L', :start_lba,
  'L', :part_size
])
PTE_LEN =
DOS_PARTITION_ENTRY.size
DOS_PT_START =
446

Instance Attribute Summary collapse

Attributes inherited from ClientHead

#end_byte_addr, #seek_pos, #size, #start_byte_addr

Instance Method Summary collapse

Methods inherited from ClientHead

#close, #mod_read, #mod_write, #read, #seek, #write

Methods included from ExportMethods

#delegate, #delegate=, #exported?, included, #method_missing, #respond_to_missing?

Constructor Details

#initialize(disk, ptype, pnum, start_lba, end_lba) ⇒ Partition

Returns a new instance of Partition.



26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/virt_disk/partition.rb', line 26

def initialize(disk, ptype, pnum, start_lba, end_lba)
  super(disk)

  @start_lba        = start_lba
  @end_lba          = end_lba
  @ptype            = ptype
  @pnum             = pnum
  @start_byte_addr  = @start_lba * block_size
  @end_byte_addr    = @end_lba * block_size
  @seek_pos         = @start_byte_addr
  @size             = @end_byte_addr - @start_byte_addr
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class VirtDisk::ExportMethods

Instance Attribute Details

#end_lbaObject (readonly)

Returns the value of attribute end_lba.



5
6
7
# File 'lib/virt_disk/partition.rb', line 5

def end_lba
  @end_lba
end

#pnumObject (readonly)

Returns the value of attribute pnum.



5
6
7
# File 'lib/virt_disk/partition.rb', line 5

def pnum
  @pnum
end

#ptypeObject (readonly)

Returns the value of attribute ptype.



5
6
7
# File 'lib/virt_disk/partition.rb', line 5

def ptype
  @ptype
end

#start_lbaObject (readonly)

Returns the value of attribute start_lba.



5
6
7
# File 'lib/virt_disk/partition.rb', line 5

def start_lba
  @start_lba
end