+usage() {
+ cat <<EOF
+usage: $0 SUBVOL_MOUNTPOINT...
+
+In git, this is not not executable because it's meant to be installed
+using ./install-my-scripts
+
+If latest subvols \$@ are not mounted, exit 1, print message, and touch
+/nocow/btrfs-stale/\$subvol
+
+Either SUBVOL_MOUNTPOINT is a snapshot of the latest, or
+the latest snapshot is snapshot of SUBVOL_MOUNTPOINT.
+
+-d Enable debug output
+-h|--help Print help and exit.
+
+Note: Uses GNU getopt options parsing style
+EOF
+ exit $1
+}
+
+##### begin command line parsing ########
+
+debug=false # default
+temp=$(getopt -l help,d hd "$@") || usage 1
+eval set -- "$temp"
+while true; do
+ case $1 in
+ -d) debug=true; shift ;;
+ -h|--help) usage ;;
+ --) shift; break ;;
+ *) echo "$0: Internal error! unexpected args: $*" ; exit 1 ;;
+ esac
+done
+
+if [[ ! $@ ]]; then
+ echo "$0: error: expected mountpoint argument"
+fi
+
+stale-file() {
+ stale_dir=/nocow/btrfs-stale
+ stale_file=$stale_dir/$vol
+ if $stale; then
+ mkdir -p $stale_dir
+ printf "%s\n" $freshest_snap > $stale_file
+ ret=1
+ else
+ rm -f $stale_file
+ fi
+
+}
+d() {
+ if $debug; then
+ printf "%s\n" "$*"
+ fi
+}
+