Class: XFS::BmapBTreeRecord

Inherits:
Object
  • Object
show all
Defined in:
lib/fs/xfs/bmap_btree_record.rb

Constant Summary collapse

BMBT_EXNTFLAG_BITLEN =
1
BMBT_STARTOFF_BITLEN =
54
BMBT_STARTBLOCK_BITLEN =
52
BMBT_BLOCKCOUNT_BITLEN =
21
XFS_EXT_NORM =
0
XFS_EXT_UNWRITTEN =
1

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data, sb) ⇒ BmapBTreeRecord

Returns a new instance of BmapBTreeRecord.



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/fs/xfs/bmap_btree_record.rb', line 45

def initialize(data, sb)
  raise "XFS::BmapBTreeRec: Nil buffer" if data.nil?
  @record          = BMAP_BTREE_REC.decode(data)
  @start_offset    = bmbt_get_start_offset(@record['l0'])
  start_block     = bmbt_get_start_block(@record['l1'])
  big_start_block = bmbt_get_big_start_block(@record['l0'], @record['l1'])
  @block_count     = bmbt_get_block_count(@record['l1'])
  @flag            = bmbt_get_state(@record['l0'])
  agno             = sb.fsb_to_agno(start_block)
  agbno            = sb.fsb_to_agbno(start_block)
  @start_block     = sb.agbno_to_real_block(agno, agbno)
  agno             = sb.fsb_to_agno(big_start_block)
  agbno            = sb.fsb_to_agbno(big_start_block)
  @big_start_block = sb.agbno_to_real_block(agno, agbno)
end

Instance Attribute Details

#big_start_blockObject

Returns the value of attribute big_start_block.



17
18
19
# File 'lib/fs/xfs/bmap_btree_record.rb', line 17

def big_start_block
  @big_start_block
end

#block_countObject

Returns the value of attribute block_count.



17
18
19
# File 'lib/fs/xfs/bmap_btree_record.rb', line 17

def block_count
  @block_count
end

#flagObject

Returns the value of attribute flag.



17
18
19
# File 'lib/fs/xfs/bmap_btree_record.rb', line 17

def flag
  @flag
end

#key_ptrObject

Returns the value of attribute key_ptr.



17
18
19
# File 'lib/fs/xfs/bmap_btree_record.rb', line 17

def key_ptr
  @key_ptr
end

#start_blockObject

Returns the value of attribute start_block.



17
18
19
# File 'lib/fs/xfs/bmap_btree_record.rb', line 17

def start_block
  @start_block
end

#start_offsetObject

Returns the value of attribute start_offset.



17
18
19
# File 'lib/fs/xfs/bmap_btree_record.rb', line 17

def start_offset
  @start_offset
end

Instance Method Details

#bmbt_get_big_start_block(word0, word1) ⇒ Object



41
42
43
# File 'lib/fs/xfs/bmap_btree_record.rb', line 41

def bmbt_get_big_start_block(word0, word1)
  ((word0 & xfs_mask64lo(9) << 43)) | (word1 >> 21)
end

#bmbt_get_block_count(doubleword) ⇒ Object



29
30
31
# File 'lib/fs/xfs/bmap_btree_record.rb', line 29

def bmbt_get_block_count(doubleword)
  doubleword & xfs_mask64lo(21)
end

#bmbt_get_start_block(doubleword) ⇒ Object



37
38
39
# File 'lib/fs/xfs/bmap_btree_record.rb', line 37

def bmbt_get_start_block(doubleword)
  doubleword >> 21
end

#bmbt_get_start_offset(doubleword) ⇒ Object



33
34
35
# File 'lib/fs/xfs/bmap_btree_record.rb', line 33

def bmbt_get_start_offset(doubleword)
  (doubleword & xfs_mask64lo(64 - BMBT_EXNTFLAG_BITLEN)) >> 9
end

#bmbt_get_state(doubleword) ⇒ Object



23
24
25
26
27
# File 'lib/fs/xfs/bmap_btree_record.rb', line 23

def bmbt_get_state(doubleword)
  flag = doubleword >> (64 - BMBT_EXNTFLAG_BITLEN)
  return XFS_EXT_UNWRITTEN if flag > 0
  XFS_EXT_NORM
end

#dumpObject



70
71
72
73
74
75
76
77
78
# File 'lib/fs/xfs/bmap_btree_record.rb', line 70

def dump
  out = "\#<#{self.class}:0x#{format('%08x', object_id)}>\n"
  out += "Offset       : #{@start_offset}\n"
  out += "Start Block  : #{@start_block}\n"
  out += "Big Start Blk: #{@big_start_block}\n"
  out += "Block Count  : #{@block_count}\n"
  out += "Flag         : #{@flag}\n"
  out
end

#set_record(cursor, level, key_number, block) ⇒ Object



61
62
63
64
65
66
67
68
# File 'lib/fs/xfs/bmap_btree_record.rb', line 61

def set_record(cursor, level, key_number, block)
  super
  if level == 0
    record       = btree_rec_addr(cursor, key_number, block)
    @start_inode = record.start_inode
  end
  @key_pointer = btree_key_address(cursor, key_number, block)
end

#xfs_mask64lo(shift) ⇒ Object



19
20
21
# File 'lib/fs/xfs/bmap_btree_record.rb', line 19

def xfs_mask64lo(shift)
  (1 << shift) - 1
end