1 # Filters for btrfs command output
5 # Some, but not all, commands emit "Btrfs <version>"
6 _filter_btrfs_version()
8 sed -e "s/^[Bb]trfs.*//g"
13 sed -e "s/\(devid\)\s\+[0-9]\+/\1 <DEVID>/g"
16 # If passed a number as first arg, filter that number of devices
17 # If passed a UUID as second arg, filter that exact UUID
18 _filter_btrfs_filesystem_show()
22 NUM_SUBST="<EXACTNUM>"
33 # the uniq collapses all device lines into 1
34 _filter_uuid $UUID | _filter_scratch | _filter_scratch_pool | \
35 _filter_size | _filter_btrfs_version | _filter_devid | \
37 sed -e "s/\(Total devices\) $NUMDEVS/\1 $NUM_SUBST/g" | \
41 # This eliminates all numbers, and shows only unique lines,
42 # to accomodate a varying nr. of devices.
43 # If given an argument, make sure we saw that many devices
45 _filter_btrfs_device_stats()
51 NUMDEVS="thiswillnotmatch"
55 _filter_scratch | _filter_scratch_pool | \
56 sed -e "s/[0-9]\+$/<NUM>/g" | sort | uniq $UNIQ_OPT | \
57 sed -e "s/ *$NUMDEVS /<NUMDEVS> /g"
60 _filter_transaction_commit() {
61 sed -e "/Transaction commit: none (default)/d" | \
62 sed -e "s/Delete subvolume (.*commit):/Delete subvolume/g"
65 _filter_btrfs_subvol_delete()
67 _filter_scratch | _filter_transaction_commit
71 # filter name of the property from the output, optionally verify against $1
72 # recognized message(s):
73 # "object is not compatible with property: label"
74 _filter_btrfs_prop_error()
76 if ! [ -z "$1" ]; then
77 sed -e "s/\(compatible with property\): $1/\1/"
79 sed -e "s/^\(.*compatible with property\).*/\1/"
83 # make sure this script returns success