Sha256: 6abe616ddd07d9052fdfbe1d7887fda472eae0176142c0b335ef5413093ff78d

Contents?: true

Size: 1.18 KB

Versions: 52

Compression:

Stored size: 1.18 KB

Contents

module ReiserFSProbe
  REISERFS_DISK_OFFSET_NEW = 64 * 1024
  REISERFS_DISK_OFFSET_OLD = 8 * 1024

  REISERFS_SUPER_SIZE   = 204

  REISERFS_MAGIC_OFFSET = 52
  REISERFS_MAGIC_SIZE   = 10

  REISERFS_MAGIC1 = "ReIsErFs".freeze
  REISERFS_MAGIC2 = "ReIsEr2Fs".freeze
  REISERFS_MAGIC3 = "ReIsEr3Fs".freeze

  def self.probe(dobj)
    return true if ReiserFSProbe.isMagic?(ReiserFSProbe.getMagic(dobj, REISERFS_DISK_OFFSET_NEW))
    return true if ReiserFSProbe.isMagic?(ReiserFSProbe.getMagic(dobj, REISERFS_DISK_OFFSET_OLD))

    # No ReiserFS.
    false
  end

  def self.getMagic(dobj, offset)
    return false unless dobj.kind_of?(MiqDisk)

    # Assume ReiserFS - read superblock at desired offset.
    dobj.seek(offset) # new disk start offset.
    sb = dobj.read(REISERFS_SUPER_SIZE)

    return nil if sb.nil?
    return nil if sb.size < (REISERFS_MAGIC_OFFSET + REISERFS_MAGIC_SIZE - 1)

    # Check magic at offset 52 for accepted ReiserFS identifiers.
    magic = sb[REISERFS_MAGIC_OFFSET, REISERFS_MAGIC_SIZE].strip
  end

  def self.isMagic?(magic)
    return true if magic == REISERFS_MAGIC1
    return true if magic == REISERFS_MAGIC2
    return true if magic == REISERFS_MAGIC3
    false
  end
end

Version data entries

52 entries across 52 versions & 1 rubygems

Version Path
manageiq-smartstate-0.10.1 lib/fs/MiqFS/modules/ReiserFSProbe.rb
manageiq-smartstate-0.10.0 lib/fs/MiqFS/modules/ReiserFSProbe.rb
manageiq-smartstate-0.9.0 lib/fs/MiqFS/modules/ReiserFSProbe.rb
manageiq-smartstate-0.8.1 lib/fs/MiqFS/modules/ReiserFSProbe.rb
manageiq-smartstate-0.8.0 lib/fs/MiqFS/modules/ReiserFSProbe.rb
manageiq-smartstate-0.7.0 lib/fs/MiqFS/modules/ReiserFSProbe.rb
manageiq-smartstate-0.6.2 lib/fs/MiqFS/modules/ReiserFSProbe.rb
manageiq-smartstate-0.5.10 lib/fs/MiqFS/modules/ReiserFSProbe.rb
manageiq-smartstate-0.3.10 lib/fs/MiqFS/modules/ReiserFSProbe.rb
manageiq-smartstate-0.6.1 lib/fs/MiqFS/modules/ReiserFSProbe.rb
manageiq-smartstate-0.3.9 lib/fs/MiqFS/modules/ReiserFSProbe.rb
manageiq-smartstate-0.6.0 lib/fs/MiqFS/modules/ReiserFSProbe.rb
manageiq-smartstate-0.5.9 lib/fs/MiqFS/modules/ReiserFSProbe.rb
manageiq-smartstate-0.5.8 lib/fs/MiqFS/modules/ReiserFSProbe.rb
manageiq-smartstate-0.3.8 lib/fs/MiqFS/modules/ReiserFSProbe.rb
manageiq-smartstate-0.5.7 lib/fs/MiqFS/modules/ReiserFSProbe.rb
manageiq-smartstate-0.3.7 lib/fs/MiqFS/modules/ReiserFSProbe.rb
manageiq-smartstate-0.5.6 lib/fs/MiqFS/modules/ReiserFSProbe.rb
manageiq-smartstate-0.3.6 lib/fs/MiqFS/modules/ReiserFSProbe.rb
manageiq-smartstate-0.5.5 lib/fs/MiqFS/modules/ReiserFSProbe.rb