Created
November 28, 2024 01:50
-
-
Save LevitatingBusinessMan/f0b0fc9d711d9000eab1c6f86aa70597 to your computer and use it in GitHub Desktop.
Revisions
-
LevitatingBusinessMan created this gist
Nov 28, 2024 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,8 @@ #!/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}}"