summaryrefslogtreecommitdiff
path: root/modules/syslinux/lib/facter/partid.rb
blob: 53fc37cb1afd04909a8d8065fedb4c058df4071f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Facter.add('partinfo') do
  setcode do
    obj = {}
    Dir.entries('/sys/class/block/').each do |entry|
      if entry == '.' or entry == '..' then next end
      path = "/sys/class/block/#{entry}/partition"
      if File.file?(path) then
        obj[entry] = {
          'partid' => File.read(path).strip(),
          'device' => File.basename(File.dirname(File.readlink("/sys/class/block/#{entry}"))),
        }
      end
    end
    obj
  end
end