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.10.1 lib/fs/xfs/directory_data_header.rb
manageiq-smartstate-0.10.0 lib/fs/xfs/directory_data_header.rb
manageiq-smartstate-0.9.0 lib/fs/xfs/directory_data_header.rb
manageiq-smartstate-0.8.1 lib/fs/xfs/directory_data_header.rb
manageiq-smartstate-0.8.0 lib/fs/xfs/directory_data_header.rb
manageiq-smartstate-0.7.0 lib/fs/xfs/directory_data_header.rb
manageiq-smartstate-0.6.2 lib/fs/xfs/directory_data_header.rb
manageiq-smartstate-0.5.10 lib/fs/xfs/directory_data_header.rb
manageiq-smartstate-0.3.10 lib/fs/xfs/directory_data_header.rb
manageiq-smartstate-0.6.1 lib/fs/xfs/directory_data_header.rb
manageiq-smartstate-0.3.9 lib/fs/xfs/directory_data_header.rb
manageiq-smartstate-0.6.0 lib/fs/xfs/directory_data_header.rb
manageiq-smartstate-0.5.9 lib/fs/xfs/directory_data_header.rb
manageiq-smartstate-0.5.8 lib/fs/xfs/directory_data_header.rb
manageiq-smartstate-0.3.8 lib/fs/xfs/directory_data_header.rb
manageiq-smartstate-0.5.7 lib/fs/xfs/directory_data_header.rb
manageiq-smartstate-0.3.7 lib/fs/xfs/directory_data_header.rb
manageiq-smartstate-0.5.6 lib/fs/xfs/directory_data_header.rb
manageiq-smartstate-0.3.6 lib/fs/xfs/directory_data_header.rb
manageiq-smartstate-0.5.5 lib/fs/xfs/directory_data_header.rb