85c4c1
diff --git a/common.sh b/common.sh
85c4c1
index c2c5f46..8fb3c5f 100644
85c4c1
--- a/common.sh
85c4c1
+++ b/common.sh
85c4c1
@@ -155,6 +155,7 @@ parse_proc_mounts () {
85c4c1
 	done
85c4c1
 }
85c4c1
 
85c4c1
+# add forth parameter to pickup btrfs subvol info
85c4c1
 parsefstab () {
85c4c1
 	while read -r line; do
85c4c1
 		case "$line" in
85c4c1
@@ -165,12 +166,22 @@ parsefstab () {
85c4c1
 				set -f
85c4c1
 				set -- $line
85c4c1
 				set +f
85c4c1
-				printf '%s %s %s\n' "$1" "$2" "$3"
85c4c1
+				printf '%s %s %s %s\n' "$1" "$2" "$3" "$4"
85c4c1
 			;;
85c4c1
 		esac
85c4c1
 	done
85c4c1
 }
85c4c1
 
85c4c1
+#check_btrfs_mounted $bootsv $bootuuid)
85c4c1
+check_btrfs_mounted () {
85c4c1
+	bootsv="$1"
85c4c1
+	bootuuid="$2"
85c4c1
+	bootdev=$(blkid | grep "$bootuuid" | cut -d ':' -f  1)
85c4c1
+	bindfrom=$(grep " btrfs " /proc/self/mountinfo |
85c4c1
+		   grep " $bootdev " | grep " /$bootsv " | cut -d ' ' -f 5)
85c4c1
+	printf "%s" "$bindfrom"
85c4c1
+}
85c4c1
+
85c4c1
 unescape_mount () {
85c4c1
 	printf %s "$1" | \
85c4c1
 		sed 's/\\011/	/g; s/\\012/\n/g; s/\\040/ /g; s/\\134/\\/g'
85c4c1
diff --git a/linux-boot-prober b/linux-boot-prober
85c4c1
index e32dc84..2a60fa2 100755
85c4c1
--- a/linux-boot-prober
85c4c1
+++ b/linux-boot-prober
85c4c1
@@ -5,16 +5,143 @@ set -e
85c4c1
 
85c4c1
 newns "$@"
85c4c1
 require_tmpdir
85c4c1
+ERR="n"
85c4c1
+
85c4c1
+tmpmnt=/var/lib/os-prober/mount
85c4c1
+if [ ! -d "$tmpmnt" ]; then
85c4c1
+	mkdir "$tmpmnt"
85c4c1
+fi
85c4c1
+
85c4c1
+mounted=
85c4c1
+bootmnt=
85c4c1
+bootsv=
85c4c1
+bootuuid=
85c4c1
 
85c4c1
 grep "^/dev/" /proc/mounts | parse_proc_mounts >"$OS_PROBER_TMP/mounted-map" || true
85c4c1
 
85c4c1
-partition="$1"
85c4c1
+if [ -z "$1" ]; then
85c4c1
+	ERR=y
85c4c1
+elif [ "$1" = btrfs -a -z "$2" ]; then
85c4c1
+	ERR=y
85c4c1
+elif [ "$1" = btrfs -a -z "$3" ]; then
85c4c1
+	ERR=y
85c4c1
+elif [ "$1" = btrfs ]; then
85c4c1
+	type=btrfs
85c4c1
+	echo "$2" | grep -q "^UUID=" || ERR=y
85c4c1
+	echo "$3" | grep -q "^subvol=" || ERR=y
85c4c1
+	export "$2"
85c4c1
+	export "$3"
85c4c1
+	partition=$(blkid | grep "$UUID" | cut -d ':' -f 1 | tr '\n' ' ' | cut -d ' ' -f 1)
85c4c1
+	debug "btrfs: partition=$partition, UUID=$UUID, subvol=$subvol"
85c4c1
+else
85c4c1
+	partition="$1"
85c4c1
+	type=other
85c4c1
+fi
85c4c1
 
85c4c1
-if [ -z "$partition" ]; then
85c4c1
+if [ "x$ERR" != xn ]; then
85c4c1
 	echo "usage: linux-boot-prober partition" >&2
85c4c1
+	echo "       linux-boot-prober btrfs UUID=<> subvol=<>" >&2
85c4c1
 	exit 1
85c4c1
 fi
85c4c1
 
85c4c1
+if [ "$type" = btrfs ]; then
85c4c1
+	# handle all of the btrfs stuff here
85c4c1
+	if [ ! -e "/proc/self/mountinfo" ]; then
85c4c1
+		warn "/proc/self/mountinfo does not exist, exiting"
85c4c1
+		umount "$tmpmnt" 2>/dev/null
85c4c1
+		rmdir "$tmpmnt" 2>/dev/null
85c4c1
+		exit 1
85c4c1
+	fi
85c4c1
+	mpoint=$(grep "btrfs" /proc/self/mountinfo | grep " /$subvol " | grep " $partition " | cut -d ' ' -f 5)
85c4c1
+	if [ "$mpoint" = "/" ]; then
85c4c1
+		warn "specifying active root not valid, exiting"
85c4c1
+		umount "$tmpmnt" 2>/dev/null
85c4c1
+		rmdir "$tmpmnt" 2>/dev/null
85c4c1
+		exit 1
85c4c1
+	fi
85c4c1
+	if [ "$mpoint" = "$tmpmnt" ]; then
85c4c1
+		warn "btrfs subvol=$subvool, UUID=$UUID, already mounted on $tmpmnt **ERROR**"
85c4c1
+		umount "$tmpmnt" 2>/dev/null
85c4c1
+		rmdir "$tmpmnt" 2>/dev/null
85c4c1
+		exit 1
85c4c1
+	fi
85c4c1
+	if [ -z "$mpoint" ]; then
85c4c1
+		# mount the btrfs root
85c4c1
+		if ! mount -o subvol=$subvol -t btrfs -U $UUID "$tmpmnt" 2>/dev/null; then
85c4c1
+			warn "error mounting btrfs subvol=$subvol UUID=$UUID"
85c4c1
+			umount "$tmpmnt/boot" 2>/dev/null
85c4c1
+			umount "$tmpmnt" 2>/dev/null
85c4c1
+			rmdir "$tmpmnt" 2>/dev/null
85c4c1
+			exit 1
85c4c1
+		fi
85c4c1
+	else
85c4c1
+		# bind-mount
85c4c1
+		if ! mount -o bind "$mpoint" "$tmpmnt" 2>/dev/null; then
85c4c1
+			warn "error mounting btrfs bindfrom=$mpoint subvol=$subvol UUID=$UUID"
85c4c1
+			umount "$tmpmnt/boot" 2>/dev/null
85c4c1
+			umount "$tmpmnt" 2>/dev/null
85c4c1
+			rmdir "$tmpmnt" 2>/dev/null
85c4c1
+			exit 1
85c4c1
+		fi
85c4c1
+	fi
85c4c1
+	debug "mounted btrfs $partition, subvol=$subvol on $tmpmnt"
85c4c1
+	if [ ! -e "$tmpmnt/etc/fstab" ]; then
85c4c1
+		warn "btrfs subvol=$subvol not root"
85c4c1
+		umount "$tmpmnt" 2>/dev/null
85c4c1
+		rmdir "$tmpmnt" 2>/dev/null
85c4c1
+		exit 1
85c4c1
+	fi
85c4c1
+	bootmnt=$(parsefstab < "$tmpmnt/etc/fstab" | grep " /boot ") || true
85c4c1
+	if [ -z "$bootmnt" ]; then
85c4c1
+		# /boot is part of the root
85c4c1
+		bootpart="$partition"
85c4c1
+		bootsv="$subvol"
85c4c1
+	elif echo "$bootmnt" | cut -d ' ' -f 3 | grep -q "btrfs"; then
85c4c1
+		# separate btrfs /boot subvolume
85c4c1
+		bootsv=$(echo "$bootmnt" | cut -d ' ' -f 4 | grep "^subvol=" | sed "s/subvol=//" )
85c4c1
+		bootuuid=$(echo "$bootmnt" | cut -d ' ' -f 1 | grep "^UUID=" | sed "s/UUID=//" )
85c4c1
+		debug "mounting btrfs $tmpmnt/boot UUID=$bootuuid subvol=$bootsv"
85c4c1
+		bindfrom=$(check_btrfs_mounted $bootsv $bootuuid)
85c4c1
+		if [ -n "$bindfrom" ]; then
85c4c1
+			# already mounted some place
85c4c1
+			if ! mount -o bind $bindfrom "$tmpmnt/boot" 2>/dev/null; then
85c4c1
+				warn "error bind mounting btrfs boot subvol=$bootsv, from=$bindfrom"
85c4c1
+				umount "$tmpmnt/boot" 2>/dev/null
85c4c1
+				umount "$tmpmnt" 2>/dev/null
85c4c1
+				rmdir "$tmpmnt" 2>/dev/null
85c4c1
+				exit 1
85c4c1
+			fi
85c4c1
+		elif ! mount -o subvol=$bootsv -t btrfs -U $bootuuid "$tmpmnt/boot" 2>/dev/null; then
85c4c1
+			warn "error mounting btrfs boot partition subvol=$bootsv, UUID=$bootuuid"
85c4c1
+			umount "$tmpmnt/boot" 2>/dev/null
85c4c1
+			umount "$tmpmnt" 2>/dev/null
85c4c1
+			rmdir "$tmpmnt" 2>/dev/null
85c4c1
+			exit 1
85c4c1
+		fi
85c4c1
+		bootpart=$(grep " btrfs " /proc/self/mountinfo | grep " /$bootsv " | cut -d ' ' -f 10)
85c4c1
+	else
85c4c1
+		# non-btrfs partition or logical volume
85c4c1
+		linux_mount_boot $partition $tmpmnt
85c4c1
+		bootpart="${mountboot%% *}"
85c4c1
+		bootsv=
85c4c1
+	fi
85c4c1
+
85c4c1
+	test="/usr/lib/linux-boot-probes/mounted/40grub2"
85c4c1
+	if [ -f $test ] && [ -x $test ]; then
85c4c1
+		debug "running $test $partition $bootpart $tmpmnt $type $subvol $bootsv"
85c4c1
+		if $test "$partition" "$bootpart" "$tmpmnt" "$type" "$subvol" "$bootsv"; then
85c4c1
+			debug "$test succeeded"
85c4c1
+		fi
85c4c1
+	fi
85c4c1
+	umount "$tmpmnt/boot" 2>/dev/null || true
85c4c1
+	if ! umount "$tmpmnt" 2>/dev/null; then
85c4c1
+		warn "problem umount $tmpmnt"
85c4c1
+	fi
85c4c1
+	rmdir "$tmpmnt" 2>/dev/null || true
85c4c1
+
85c4c1
+	exit 0
85c4c1
+fi
85c4c1
+
85c4c1
 if ! mapped="$(mapdevfs "$partition")"; then
85c4c1
 	log "Device '$partition' does not exist; skipping"
85c4c1
 	continue
85c4c1
@@ -22,8 +149,8 @@ fi
85c4c1
 
85c4c1
 if ! grep -q "^$mapped " "$OS_PROBER_TMP/mounted-map"; then
85c4c1
 	for test in /usr/lib/linux-boot-probes/*; do
85c4c1
-		debug "running $test"
85c4c1
 		if [ -x $test ] && [ -f $test ]; then
85c4c1
+			debug "running $test"
85c4c1
 			if $test "$partition"; then
85c4c1
 				debug "linux detected by $test"
85c4c1
 				break
85c4c1
diff --git a/linux-boot-probes/mounted/common/40grub2 b/linux-boot-probes/mounted/common/40grub2
85c4c1
index 885614e..db5cbfd 100755
85c4c1
--- a/linux-boot-probes/mounted/common/40grub2
85c4c1
+++ b/linux-boot-probes/mounted/common/40grub2
85c4c1
@@ -2,17 +2,30 @@
85c4c1
 . /usr/share/os-prober/common.sh
85c4c1
 set -e
85c4c1
 
85c4c1
+# add support for btrfs with no separate /boot
85c4c1
+# that is, rootsv = bootsv
85c4c1
 partition="$1"
85c4c1
 bootpart="$2"
85c4c1
 mpoint="$3"
85c4c1
 type="$4"
85c4c1
+rootsv="$5"
85c4c1
+bootsv="$6"
85c4c1
 
85c4c1
 found_item=0
85c4c1
 
85c4c1
 entry_result () {
85c4c1
+	if [ "x$type" = "xbtrfs" -a "$partition" = "$bootpart" ]; then
85c4c1
+		# trim off the leading subvol
85c4c1
+		kernelfile=$(echo "$kernel" | cut -d '/' -f 2- | cut -d '/' -f 2-)
85c4c1
+		if [ "x$rootsv" != "x$bootsv" ]; then
85c4c1
+		   kernelfile="/boot/$kernelfile"
85c4c1
+		fi
85c4c1
+	else
85c4c1
+		kernelfile=$kernel
85c4c1
+	fi
85c4c1
 	if [ "$ignore_item" = 0 ] && \
85c4c1
 	   [ -n "$kernel" ] && \
85c4c1
-	   [ -e "$mpoint/$kernel" ]; then
85c4c1
+	   [ -e "$mpoint/$kernelfile" ]; then
85c4c1
 		result "$rootpart:$bootpart:$title:$kernel:$initrd:$parameters"
85c4c1
 		found_item=1
85c4c1
 	fi
85c4c1
diff --git a/os-prober b/os-prober
85c4c1
index 8852887..482c3c2 100755
85c4c1
--- a/os-prober
85c4c1
+++ b/os-prober
85c4c1
@@ -76,9 +76,12 @@ partitions () {
85c4c1
 
85c4c1
 	# Also detect OSes on LVM volumes (assumes LVM is active)
85c4c1
 	if type lvs >/dev/null 2>&1; then
85c4c1
-		echo "$(LVM_SUPPRESS_FD_WARNINGS=1 log_output lvs --noheadings --separator : -o vg_name,lv_name |
85c4c1
+		echo "$(LVM_SUPPRESS_FD_WARNINGS=1 log_output lvs --noheadings --separator : -o vg_name,lv_name 2>/dev/null |
85c4c1
 			sed "s|-|--|g;s|^[[:space:]]*\(.*\):\(.*\)$|/dev/mapper/\1-\2|")"
85c4c1
 	fi
85c4c1
+
85c4c1
+	# now lets make sure we got all of the btrfs partitions and disks
85c4c1
+	blkid | grep 'TYPE="btrfs"' | cut -d ':' -f 1
85c4c1
 }
85c4c1
 
85c4c1
 parse_proc_swaps () {
85c4c1
@@ -136,6 +139,8 @@ if [ -f /proc/mdstat ] ; then
85c4c1
 	grep "^md" /proc/mdstat | cut -d: -f2- | parse_proc_mdstat >"$OS_PROBER_TMP/raided-map" || true
85c4c1
 fi
85c4c1
 
85c4c1
+: >"$OS_PROBER_TMP/btrfs-vols"
85c4c1
+
85c4c1
 for partition in $(partitions); do
85c4c1
 	if ! mapped="$(mapdevfs "$partition")"; then
85c4c1
 		log "Device '$partition' does not exist; skipping"
85c4c1
@@ -154,7 +159,26 @@ for partition in $(partitions); do
85c4c1
 		continue
85c4c1
 	fi
85c4c1
 
85c4c1
-	if ! grep -q "^$mapped " "$OS_PROBER_TMP/mounted-map" ; then
85c4c1
+	# do btrfs processing here; both mounted and unmounted will
85c4c1
+	# be handled by 50mounted-tests so we can do a subvol only once.
85c4c1
+	type=$(blkid -o value -s TYPE $mapped || true)
85c4c1
+	if [ "$type" = btrfs ]; then
85c4c1
+		uuid=$(blkid -o value -s UUID $mapped)
85c4c1
+		if grep -q "^$uuid" "$OS_PROBER_TMP/btrfs-vols" ; then
85c4c1
+			continue
85c4c1
+		fi
85c4c1
+		debug "btrfs volume uuid=$uuid partition=$partition"
85c4c1
+		echo "$uuid" >>"$OS_PROBER_TMP/btrfs-vols"
85c4c1
+		test="/usr/lib/os-probes/50mounted-tests"
85c4c1
+		if [ -f "$test" ] && [ -x "$test" ]; then
85c4c1
+			debug "running $test on btrfs $partition"
85c4c1
+			if "$test" btrfs "$uuid" "$partition"; then
85c4c1
+				debug "os detected by $test"
85c4c1
+				continue
85c4c1
+			fi
85c4c1
+		fi
85c4c1
+
85c4c1
+	elif ! grep -q "^$mapped " "$OS_PROBER_TMP/mounted-map" ; then
85c4c1
 		for test in /usr/lib/os-probes/*; do
85c4c1
 			if [ -f "$test" ] && [ -x "$test" ]; then
85c4c1
 				debug "running $test on $partition"
85c4c1
diff --git a/os-probes/common/50mounted-tests b/os-probes/common/50mounted-tests
85c4c1
index 2951ef9..e33eb82 100755
85c4c1
--- a/os-probes/common/50mounted-tests
85c4c1
+++ b/os-probes/common/50mounted-tests
85c4c1
@@ -19,19 +19,31 @@ do_unmount() {
85c4c1
 	rmdir "$tmpmnt" || true
85c4c1
 }
85c4c1
 
85c4c1
-types="$(fs_type "$partition")"
85c4c1
+if [ "x$1" = xbtrfs ]; then
85c4c1
+	types=btrfs
85c4c1
+	if [ -z "$2" -o -z "$3" ]; then
85c4c1
+		debug "missing btrfs parameters, exiting"
85c4c1
+		exit 1
85c4c1
+	fi
85c4c1
+	UUID="$2"
85c4c1
+	BTRFSDEV="$3"
85c4c1
+else
85c4c1
+	partition="$1"
85c4c1
+	types="$(fs_type "$partition")" || types=NOT-DETECTED
85c4c1
+fi
85c4c1
+
85c4c1
 if [ "$types" = NOT-DETECTED ]; then
85c4c1
 	debug "$1 type not recognised; skipping"
85c4c1
-	exit 0
85c4c1
+	exit 1
85c4c1
 elif [ "$types" = swap ]; then
85c4c1
 	debug "$1 is a swap partition; skipping"
85c4c1
-	exit 0
85c4c1
+	exit 1
85c4c1
 elif [ "$types" = crypto_LUKS ]; then
85c4c1
 	debug "$1 is a LUKS partition; skipping"
85c4c1
-	exit 0
85c4c1
+	exit 1
85c4c1
 elif [ "$types" = LVM2_member ]; then
85c4c1
 	debug "$1 is an LVM member; skipping"
85c4c1
-	exit 0
85c4c1
+	exit 1
85c4c1
 elif [ "$types" = ntfs ]; then
85c4c1
 	if type ntfs-3g >/dev/null 2>&1; then
85c4c1
 		types='ntfs-3g ntfs'
85c4c1
@@ -40,7 +52,7 @@ elif [ -z "$types" ]; then
85c4c1
 	if type cryptsetup >/dev/null 2>&1 && \
85c4c1
 	   cryptsetup luksDump "$partition" >/dev/null 2>&1; then
85c4c1
 		debug "$1 is a LUKS partition; skipping"
85c4c1
-		exit 0
85c4c1
+		exit 1
85c4c1
 	fi
85c4c1
 	for type in $(grep -v nodev /proc/filesystems); do
85c4c1
 		# hfsplus filesystems are mountable as hfs. Try hfs last so
85c4c1
@@ -63,6 +75,108 @@ if [ ! -d "$tmpmnt" ]; then
85c4c1
 fi
85c4c1
 
85c4c1
 mounted=
85c4c1
+
85c4c1
+# all btrfs processing here.  Handle both unmounted and
85c4c1
+# mounted subvolumes.
85c4c1
+if [ "$types" = btrfs ]; then
85c4c1
+	partition="$BTRFSDEV"
85c4c1
+	debug "begin btrfs processing for $UUID"
85c4c1
+	# note that the btrfs volume must not be mounted ro
85c4c1
+	if mount -t btrfs -U "$UUID" "$tmpmnt"  2>/dev/null; then
85c4c1
+		debug "btrfs volume $UUID mounted"
85c4c1
+	else
85c4c1
+		warn "cannot mount btrfs volume $UUID, exiting"
85c4c1
+		rmdir "$tmpmnt" || true
85c4c1
+		exit 1
85c4c1
+	fi
85c4c1
+	# besides regular subvols, get ro and snapshot so thet can be excluded
85c4c1
+        subvols=$(btrfs subvolume list "$tmpmnt" | cut -d ' ' -f 9)
85c4c1
+        rosubvols=$(btrfs subvolume list -r "$tmpmnt" | cut -d ' ' -f 9)
85c4c1
+        sssubvols=$(btrfs subvolume list -s "$tmpmnt" | cut -d ' ' -f 14)
85c4c1
+        if ! umount "$tmpmnt"; then
85c4c1
+            warn "failed to umount btrfs volume on $tmpmnt"
85c4c1
+            rmdir "$tmpmnt" || true
85c4c1
+            exit 1
85c4c1
+        fi
85c4c1
+
85c4c1
+	found=
85c4c1
+	mounted=
85c4c1
+
85c4c1
+	mpoint="$(grep btrfs /proc/self/mountinfo | grep "$partition " | cut -d ' ' -f 5)"
85c4c1
+	if [ -n "$mpoint" -a "x$mpoint" = "x/" ]; then
85c4c1
+		debug "This is the root for the running system" #running system must be done elsewhere
85c4c1
+	else
85c4c1
+	    #partition was not root of running system, so lets look for bootable subvols
85c4c1
+	    if [ -n "$mpoint" ] ; then
85c4c1
+		mounted=1  #partition was already mounted,so lets not unmount it when done
85c4c1
+	    else
85c4c1
+		# again, do not mount btrfs ro
85c4c1
+		mount -t btrfs -U "$UUID" "$tmpmnt"
85c4c1
+		mpoint="$tmpmnt"
85c4c1
+	    fi
85c4c1
+
85c4c1
+	    test="/usr/lib/os-probes/mounted/90linux-distro"
85c4c1
+	    if [ -f "$test" ] && [ -x "$test" ]; then
85c4c1
+		debug "running subtest $test"
85c4c1
+		if "$test" "$partition" "$mpoint" btrfs "UUID=$UUID"; then
85c4c1
+		    debug "os found by subtest $test on $partition"
85c4c1
+		    found=1
85c4c1
+		fi
85c4c1
+	    fi
85c4c1
+	    if [ -z "$mounted" ]; then
85c4c1
+		if ! umount "$tmpmnt"; then
85c4c1
+		    warn "failed to umount $tmpmnt"
85c4c1
+		fi
85c4c1
+	    fi
85c4c1
+	fi
85c4c1
+
85c4c1
+	if [ -z "$subvols" ]; then
85c4c1
+	        debug "no subvols found on btrfs volume $UUID"
85c4c1
+	else
85c4c1
+		found=
85c4c1
+                for subvol in $subvols; do
85c4c1
+			debug "begin btrfs processing for $UUID subvol=$subvol"
85c4c1
+			if echo "$rosubvols" | grep -q -x "$subvol"; then
85c4c1
+				continue
85c4c1
+			fi
85c4c1
+			if echo "$sssubvols" | grep -q -x "$subvol"; then
85c4c1
+				continue
85c4c1
+			fi
85c4c1
+			mounted=
85c4c1
+			mpoint="$(grep btrfs /proc/self/mountinfo | grep "$partition " | grep "/$subvol " | cut -d ' ' -f 5)"
85c4c1
+			if [ -n "$mpoint" ]; then
85c4c1
+				if [ "x$mpoint" = "x/" ]; then
85c4c1
+					continue # this is the root for the running system
85c4c1
+				fi
85c4c1
+				mounted=1
85c4c1
+			else
85c4c1
+				# again, do not mount btrfs ro
85c4c1
+				mount -t btrfs -o subvol="$subvol" -U "$UUID" "$tmpmnt"
85c4c1
+				mpoint="$tmpmnt"
85c4c1
+			fi
85c4c1
+			test="/usr/lib/os-probes/mounted/90linux-distro"
85c4c1
+			if [ -f "$test" ] && [ -x "$test" ]; then
85c4c1
+				debug "running subtest $test"
85c4c1
+				if "$test" "$partition" "$mpoint" btrfs "UUID=$UUID" "subvol=$subvol"; then
85c4c1
+					debug "os found by subtest $test on subvol $subvol"
85c4c1
+					found=1
85c4c1
+				fi
85c4c1
+			fi
85c4c1
+			if [ -z "$mounted" ]; then
85c4c1
+				if ! umount "$tmpmnt"; then
85c4c1
+				    warn "failed to umount $tmpmnt"
85c4c1
+				fi
85c4c1
+			fi
85c4c1
+		done
85c4c1
+	fi
85c4c1
+	rmdir "$tmpmnt" || true
85c4c1
+	if [ "$found" ]; then
85c4c1
+		exit 0
85c4c1
+	else
85c4c1
+		exit 1
85c4c1
+	fi
85c4c1
+fi
85c4c1
+
85c4c1
 if type grub-mount >/dev/null 2>&1 && \
85c4c1
    type grub-probe >/dev/null 2>&1 && \
85c4c1
    grub-mount "$partition" "$tmpmnt" 2>/dev/null; then
85c4c1
diff --git a/os-probes/mounted/common/90linux-distro b/os-probes/mounted/common/90linux-distro
85c4c1
index badfbb1..9bc5154 100755
85c4c1
--- a/os-probes/mounted/common/90linux-distro
85c4c1
+++ b/os-probes/mounted/common/90linux-distro
85c4c1
@@ -7,6 +7,8 @@ set -e
85c4c1
 partition="$1"
85c4c1
 dir="$2"
85c4c1
 type="$3"
85c4c1
+uuid="$4"
85c4c1
+subvol="$5"
85c4c1
 
85c4c1
 # This test is inaccurate, but given separate / and /boot partitions and the
85c4c1
 # fact that only some architectures have ld-linux.so, I can't see anything
85c4c1
@@ -143,7 +145,11 @@ if (ls "$dir"/lib*/ld*.so* && [ -d "$dir/boot" ] || ls "$dir"/usr/lib*/ld*.so*)
85c4c1
 	fi
85c4c1
 	
85c4c1
         label="$(count_next_label "$short")"
85c4c1
-	result "$partition:$long:$label:linux"
85c4c1
+	if [ "x$type" = "xbtrfs" -a "x$uuid" != "x" -a "x$subvol" != "x" ]; then
85c4c1
+		result "$partition:$long:$label:linux:$type:$uuid:$subvol"
85c4c1
+	else
85c4c1
+		result "$partition:$long:$label:linux"
85c4c1
+	fi
85c4c1
 	exit 0
85c4c1
 else
85c4c1
 	exit 1