Sha256: c74309947271c78ebd84ceb941265b3261e0c6188c83021b33572bc138e7789c

Contents?: true

Size: 1.54 KB

Versions: 66

Compression:

Stored size: 1.54 KB

Contents

require 'fs/xfs/directory'
require 'fs/xfs/directory2_data_header'
require 'fs/xfs/directory3_data_header'
require 'fs/xfs/superblock'

module XFS
  DIRECTORY_DATA_FREE = BinaryStruct.new([
    'S>',  'offset',              # start of freespace
    'S>',  'length',              # length of freespace
  ])
  SIZEOF_DIRECTORY_DATA_FREE    = DIRECTORY_DATA_FREE.size

  class DirectoryDataHeader
    XFS_DIR2_DATA_FD_COUNT      = 3

    attr_reader :data_header, :header_end, :version_3

    def decode_directory_header(data, header)
      template     = header.template
      @data_header = template.decode(data)
      header.magic_numbers.each { |magic_number| return template.size if @data_header['magic'] == magic_number }
      raise "XFS::DirectoryDataHeader: Invalid Magic Number #{@data_header['magic']}"
    end

    def initialize(data, sb)
      @sb = sb
      if @sb.version_has_crc?
        version_header = Directory3DataHeader.new
      else
        version_header = Directory2DataHeader.new
      end
      @version_3 = version_header.version_3
      header_size = decode_directory_header(data, version_header)
      free_offset = header_size
      @data_free    = []
      @free_end     = 0
      (1..XFS_DIR2_DATA_FD_COUNT).each do |i|
        @free_end     = header_size + SIZEOF_DIRECTORY_DATA_FREE * i
        @data_free[i] = DIRECTORY_DATA_FREE.decode(data[free_offset..@free_end])
        free_offset   = @free_end
      end
      @header_end = @free_end
      @header_end += version_header.pad
    end
  end # class DirectoryDataHeader
end   # module XFS

Version data entries

66 entries across 66 versions & 1 rubygems

Version Path
manageiq-smartstate-0.2.18 lib/fs/xfs/directory_data_header.rb
manageiq-smartstate-0.2.17 lib/fs/xfs/directory_data_header.rb
manageiq-smartstate-0.2.16 lib/fs/xfs/directory_data_header.rb
manageiq-smartstate-0.2.15 lib/fs/xfs/directory_data_header.rb
manageiq-smartstate-0.2.14 lib/fs/xfs/directory_data_header.rb
manageiq-smartstate-0.2.13 lib/fs/xfs/directory_data_header.rb
manageiq-smartstate-0.2.12 lib/fs/xfs/directory_data_header.rb
manageiq-smartstate-0.2.11 lib/fs/xfs/directory_data_header.rb
manageiq-smartstate-0.2.10 lib/fs/xfs/directory_data_header.rb
manageiq-smartstate-0.2.9 lib/fs/xfs/directory_data_header.rb
manageiq-smartstate-0.2.8 lib/fs/xfs/directory_data_header.rb
manageiq-smartstate-0.2.7 lib/fs/xfs/directory_data_header.rb
manageiq-smartstate-0.2.6 lib/fs/xfs/directory_data_header.rb
manageiq-smartstate-0.2.5 lib/fs/xfs/directory_data_header.rb
manageiq-smartstate-0.2.4 lib/fs/xfs/directory_data_header.rb
manageiq-smartstate-0.2.3 lib/fs/xfs/directory_data_header.rb
manageiq-smartstate-0.2.2 lib/fs/xfs/directory_data_header.rb
manageiq-smartstate-0.2.1 lib/fs/xfs/directory_data_header.rb
manageiq-smartstate-0.2.0 lib/fs/xfs/directory_data_header.rb
manageiq-smartstate-0.1.6 lib/fs/xfs/directory_data_header.rb