Sophie

Sophie

distrib > Mageia > cauldron > i586 > by-pkgid > 4059bfc13bd9ebd7ee31e446c4da4903 > files > 1

os-prober-1.81-2.mga9.src.rpm

#!/bin/sh
# Sub-tests that require a mounted partition.

. /usr/share/os-prober/common.sh

if [ "x$1" = xbtrfs ]; then
	exit 1;
else
	partition="$1"
	types="$(fs_type "$partition")" || types=NOT-DETECTED
fi

if [ "$types" != "ufs" ]; then
	exit 1
else
	type="ufs"
fi

tmpmnt=/var/lib/os-prober/mount
if [ ! -d "$tmpmnt" ]; then
	mkdir "$tmpmnt"
fi

mounted=

for test in /usr/lib/os-probes/ufs/*; do
	debug "running subtest $test"
	if [ -f "$test" ] && [ -x "$test" ]; then
		"$test" "$partition" "$tmpmnt" "$type";
		result=$?
		while grep -q "^[^ ]*[ \t]\+$tmpmnt[ \t]" /proc/mounts; do
		  sleep 0.01; # otherwise unmounting would fail for any kernel/umount realted reason
		  umount "$tmpmnt" 2>/dev/null || { warn "failed to umount $tmpmnt"; sleep 0.2; }
		done
		if [[ $result -eq 0 ]]; then
  		  debug "os found by subtest $test"
		  rmdir "$tmpmnt"
  		  exit 0
		fi
	fi
done

rmdir "$tmpmnt"

# No tests found anything.
exit 1