Skip to content

Instantly share code, notes, and snippets.

@LevitatingBusinessMan
Created November 28, 2024 01:50
Show Gist options
  • Save LevitatingBusinessMan/f0b0fc9d711d9000eab1c6f86aa70597 to your computer and use it in GitHub Desktop.
Save LevitatingBusinessMan/f0b0fc9d711d9000eab1c6f86aa70597 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
volumes = `run0 btrfs subvolume list -p #{ARGV[0] || "/"}`.lines.map do
|l| l.match /^ID (?<ID>\d+) gen (?<GEN>\d+) parent (?<PARENT>\d+) top level (?<TOPLEVEL>\d+) path (?<PATH>\S+)$/
end
edges = volumes.map do
|v| "#{v[:PARENT]!="5" ? "\"#{volumes.find{|p| p[:ID] == v[:PARENT]}[:PATH]}\" -> \"#{v[:PATH]}\"" : "\"#{v[:PATH]}\""};\n"
end
puts "digraph {\n#{edges.map{|e|"\t"+e}.join}}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment