Module: LinuxMountProbe

Defined in:
lib/fs/modules/LinuxMountProbe.rb

Constant Summary collapse

LINUX_FS_TYPES =
%w( Ext3 ext3 Ext4 ext4 ReiserFS XFS )
LINUX_ROOT_DIRS =
["bin", "dev", "etc", "lib", "proc", "sbin", "usr"]
LINUX_ROOT_FILES =
["/etc/fstab"]

Class Method Summary collapse

Class Method Details

.probe(fs) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/fs/modules/LinuxMountProbe.rb', line 8

def self.probe(fs)
  unless LINUX_FS_TYPES.include?(fs.fsType)
    $log.info "LinuxMountProbe << FALSE because file system (#{fs.fsType}) is not supported" if $log
    return false
  end

  if (fs.dirEntries & LINUX_ROOT_DIRS).length != LINUX_ROOT_DIRS.length
    $log.debug "LinuxMountProbe << FALSE because root directories (#{LINUX_ROOT_DIRS.inspect}) missing in: #{fs.dirEntries.inspect}" if $log
    return false
  end

  LINUX_ROOT_FILES.each do |f|
    unless fs.fileExists?(f)
      $log.info "LinuxMountProbe << FALSE because file #{f} does not exist" if $log
      return false
    end
  end

  $log.debug "LinuxMountProbe << TRUE" if $log
  true
end