From ec094adcdcc6826e6c814efac0205c2be859e08c Mon Sep 17 00:00:00 2001 From: Andrew Cady Date: Tue, 6 Jun 2023 11:01:31 -0400 Subject: fix rootfinding logic when readonly (-r) is specified (and therefore root subvolume will not be listed) --- list-all-subvolumes | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/list-all-subvolumes b/list-all-subvolumes index ec042c7..fc19b69 100755 --- a/list-all-subvolumes +++ b/list-all-subvolumes @@ -30,13 +30,22 @@ extract_subvolume_path() [ "$path" != "$REPLY" ] path=${path#/} - abspath=$1/$path - [ -d "$abspath" ] || exit + tryroot=$1/$path + [ -d "$tryroot" ] || exit - if [ ! "$root" -a "$abspath" -ef / ] - then - root=$path - fi + while ! [ "$root" ] + do + if [ / -ef "$tryroot" ] + then + root=${tryroot#$1/} + break + elif [ "$tryroot" = / ] + then + break + else + tryroot=${tryroot%/*} + fi + done case "$path" in "$root" | "$root"/*) path=$root/.${path#$root} ;; esac -- cgit v1.2.3