Created
November 28, 2024 01:50
-
-
Save LevitatingBusinessMan/f0b0fc9d711d9000eab1c6f86aa70597 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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