Sha256: ddbde8b17ed2e3a4940e249d697190748536e1dc99689adb5351f91b46352251

Contents?: true

Size: 1.17 KB

Versions: 14

Compression:

Stored size: 1.17 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"
  REISERFS_MAGIC2 = "ReIsEr2Fs"
  REISERFS_MAGIC3 = "ReIsEr3Fs"

  def self.probe(dobj)
    return false unless dobj.kind_of?(MiqDisk)

    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)
    # 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

14 entries across 14 versions & 1 rubygems

Version Path
manageiq-smartstate-0.2.6 lib/fs/MiqFS/modules/ReiserFSProbe.rb
manageiq-smartstate-0.2.5 lib/fs/MiqFS/modules/ReiserFSProbe.rb
manageiq-smartstate-0.2.4 lib/fs/MiqFS/modules/ReiserFSProbe.rb
manageiq-smartstate-0.2.3 lib/fs/MiqFS/modules/ReiserFSProbe.rb
manageiq-smartstate-0.2.2 lib/fs/MiqFS/modules/ReiserFSProbe.rb
manageiq-smartstate-0.2.1 lib/fs/MiqFS/modules/ReiserFSProbe.rb
manageiq-smartstate-0.2.0 lib/fs/MiqFS/modules/ReiserFSProbe.rb
manageiq-smartstate-0.1.6 lib/fs/MiqFS/modules/ReiserFSProbe.rb
manageiq-smartstate-0.1.5 lib/fs/MiqFS/modules/ReiserFSProbe.rb
manageiq-smartstate-0.1.4 lib/fs/MiqFS/modules/ReiserFSProbe.rb
manageiq-smartstate-0.1.3 lib/fs/MiqFS/modules/ReiserFSProbe.rb
manageiq-smartstate-0.1.2 lib/fs/MiqFS/modules/ReiserFSProbe.rb
manageiq-smartstate-0.1.1 lib/fs/MiqFS/modules/ReiserFSProbe.rb
manageiq-smartstate-0.1.0 lib/fs/MiqFS/modules/ReiserFSProbe.rb