On 2016/04/15 10:55, Chris Murphy wrote:
Hi,

I'm realizing instead of doing 'btrfs subvolume -t' and then 'btrfs
subvolume -tr' and comparing, it would be better if -t just had a
column for whether a subvolume is ro. And maybe it's useful to know if
a subvolume is a snapshot or not (?). I'm not super picky about the
last one. But being able to see if it's ro or not is a nice to have.

In particular on openSUSE with snapper where there's a prolific amount
of snapshots, and the naming convention doesn't indicate whether
something is ro or not.


Although I'm not sure whether such changes is acceptable or not,
just FYI, you can list subvols with ro flags by the following script.

================================================================
#!/bin/ruby

IO.popen("btrfs sub list -t " + ARGV[0]) {|p_list|
  puts p_list.gets.chomp + "ro"
  puts p_list.gets.chomp + "--"
  ro = ''
  p_list.each { |l|
    l.chomp!
    path = l.split[3]
    IO.popen("btrfs property get #{ARGV[0]+path} | sed -nre 
's/^ro=(true|false)$/\\1/p'") { |p_prop|
      ro = p_prop.gets
      ro = "false" if ro.nil?
    }

    puts l + "\t" + ro
  }
}
================================================================

# NOTE: It's not well tested.

sample output:
================================================================
# ./sub-list-with-ro.rb /
ID      gen     top level       path    ro
--      ---     ---------       ----    --
257     48672   5               root    false
259     48623   257             var/lib/machines        false
452     36540   257             root/snaps/root-2016-03-18      true
457     45676   257             root/snaps/root-2016-04-08      true
================================================================

Thanks,
Satoru
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to