3 [[ $EUID == 0 ]] ||
exec sudo
-E "$BASH_SOURCE" "$@"
6 trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR
11 echo "$0: error: expected mountpoint argument"
19 if [[ ! $snaps ]]; then
23 # when a btrbk bugfix makes it into the distro,
24 # we might replace this with btrbk list latest /mnt/root/$vol | ...
25 # note: this is duplicated in mount-latest-subvol
27 for f
in ${snaps[@]}; do
28 printf "%s %s\n" $
(date -d $
(sed -r 's/(.{4})(..)(.{5})(..)(.*)/\1-\2-\3:\4:\5/' <<<${f#$vol.}) +%s
) $f
29 done |
sort -r |
head -n 1 |
awk '{print $2}'
31 if [[ ! $last_snap ]]; then
37 if btrfs sub show
$d|
sed '0,/^\t*Snapshot(s):/d;s/^\s*//' | \
38 grep -xF btrbk
/$last_snap &>/dev
/null
; then
41 last_uuid
=$
(btrfs sub show
$last_snap|
awk '$1 == "UUID:" {print $2}')
42 if btrfs sub show
$d|
grep "^\s*Parent UUID:\s*$last_uuid$" &>/dev
/null
; then
46 stale_dir
=/nocow
/btrfs-stale
47 stale_file
=$stale_dir/$vol
50 printf "%s\n" $last_snap > $stale_file