Sha256: 9ab8a494d8786d143ff4217a45e993c1e69f080cb34a6350fd2a48e2b0b38d8f

Contents?: true

Size: 996 Bytes

Versions: 4

Compression:

Stored size: 996 Bytes

Contents

# Fact: partitions
#
# Purpose:
#   Return the details of the disk partitions
#
# Resolution:
#   Parse the contents of /sys/block/<device>/size to receive the size (multiplying by 512 to correct for blocks-to-bytes)
#
# Caveats:
#   Only supports Linux 2.6+ at this time, due to the reliance on sysfs
#
# Author: Chris Portman <chris@portman.net.au>

require 'facter'
require 'facter/util/partitions'

Facter.add(:partitions) do
  confine do
    Facter::Util::Partitions.available? ? true : nil
  end

  setcode do
    partitions = {}
    Facter::Util::Partitions.list.each do |part|
      details = {}
      details['uuid']       = Facter::Util::Partitions.uuid(part)
      details['size']       = Facter::Util::Partitions.size(part)
      details['mount']      = Facter::Util::Partitions.mount(part)
      details['filesystem'] = Facter::Util::Partitions.filesystem(part)
      details.reject! {|k,v| v.nil? || v.to_s.empty? }
      partitions[part] = details
    end
    partitions
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
facter-2.1.0 lib/facter/partitions.rb
facter-2.1.0-x86-mingw32 lib/facter/partitions.rb
facter-2.1.0-x64-mingw32 lib/facter/partitions.rb
facter-2.1.0-universal-darwin lib/facter/partitions.rb