Skip to content

Instantly share code, notes, and snippets.

@LevitatingBusinessMan
Created November 28, 2024 01:50
Show Gist options
  • Select an option

  • Save LevitatingBusinessMan/f0b0fc9d711d9000eab1c6f86aa70597 to your computer and use it in GitHub Desktop.

Select an option

Save LevitatingBusinessMan/f0b0fc9d711d9000eab1c6f86aa70597 to your computer and use it in GitHub Desktop.

Revisions

  1. LevitatingBusinessMan created this gist Nov 28, 2024.
    8 changes: 8 additions & 0 deletions subvolumes2dot.rb
    Original 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}}"