summaryrefslogtreecommitdiffstats
path: root/client/shared/lib
diff options
context:
space:
mode:
Diffstat (limited to 'client/shared/lib')
-rwxr-xr-xclient/shared/lib/os-probes/10zvol-test14
-rwxr-xr-xclient/shared/lib/os-probes/50mounted-tests99
-rwxr-xr-xclient/shared/lib/os-probes/init/10filesystems39
-rwxr-xr-xclient/shared/lib/os-probes/mounted/05efi71
-rwxr-xr-xclient/shared/lib/os-probes/mounted/10freedos23
-rwxr-xr-xclient/shared/lib/os-probes/mounted/10qnx21
-rwxr-xr-xclient/shared/lib/os-probes/mounted/20macosx30
-rwxr-xr-xclient/shared/lib/os-probes/mounted/20microsoft140
-rwxr-xr-xclient/shared/lib/os-probes/mounted/30utility33
-rwxr-xr-xclient/shared/lib/os-probes/mounted/40lsb48
-rwxr-xr-xclient/shared/lib/os-probes/mounted/70hurd16
-rwxr-xr-xclient/shared/lib/os-probes/mounted/80minix28
-rwxr-xr-xclient/shared/lib/os-probes/mounted/83haiku35
-rwxr-xr-xclient/shared/lib/os-probes/mounted/90linux-distro138
-rwxr-xr-xclient/shared/lib/os-probes/mounted/90solaris19
-rwxr-xr-xclient/shared/lib/os-probes/mounted/efi/10elilo24
-rwxr-xr-xclient/shared/lib/os-probes/mounted/efi/20microsoft28
17 files changed, 806 insertions, 0 deletions
diff --git a/client/shared/lib/os-probes/10zvol-test b/client/shared/lib/os-probes/10zvol-test
new file mode 100755
index 00000000..cdbe7a5f
--- /dev/null
+++ b/client/shared/lib/os-probes/10zvol-test
@@ -0,0 +1,14 @@
+#!/bin/sh
+# Sub-test to exclude ZVOLs
+set -e
+partition="$1"
+
+. /usr/share/os-prober/common.sh
+
+if [ "$(stat -L -c %t "$partition")" = "e6" ] ; then
+ debug "$1 is a ZVOL; skipping"
+ exit 0
+fi
+
+# No ZVOLs found
+exit 1
diff --git a/client/shared/lib/os-probes/50mounted-tests b/client/shared/lib/os-probes/50mounted-tests
new file mode 100755
index 00000000..6f4d7afd
--- /dev/null
+++ b/client/shared/lib/os-probes/50mounted-tests
@@ -0,0 +1,99 @@
+#!/bin/sh
+# Sub-tests that require a mounted partition.
+set -e
+partition="$1"
+
+. /usr/share/os-prober/common.sh
+
+types="$(fs_type "$partition")" || types=NOT-DETECTED
+if [ "$types" = NOT-DETECTED ] || [ -z "$types" ]; then
+ debug "$1 type not recognised; skipping"
+ exit 0
+elif [ "$types" = swap ]; then
+ debug "$1 is a swap partition; skipping"
+ exit 0
+elif [ "$types" = LVM2_member ]; then
+ debug "$1 is a LVM member partition; skipping"
+ exit 0
+elif [ "$types" = crypto_LUKS ]; then
+ debug "$1 is a LUKS partition; skipping"
+ exit 0
+elif [ "$types" = ntfs ]; then
+ if type ntfs-3g >/dev/null 2>&1; then
+ types='ntfs-3g ntfs'
+ fi
+elif [ -z "$types" ]; then
+ if type cryptsetup >/dev/null 2>&1 && \
+ cryptsetup luksDump "$partition" >/dev/null 2>&1; then
+ debug "$1 is a LUKS partition; skipping"
+ exit 0
+ fi
+ for type in $(grep -v nodev /proc/filesystems); do
+ # hfsplus filesystems are mountable as hfs. Try hfs last so
+ # that we can tell the difference.
+ if [ "$type" = hfs ]; then
+ delaytypes="${delaytypes:+$delaytypes }$type"
+ elif [ "$type" = fuseblk ]; then
+ if type ntfs-3g >/dev/null 2>&1; then
+ types="${types:+$types }ntfs-3g"
+ fi
+ else
+ types="${types:+$types }$type"
+ fi
+ done
+fi
+
+tmpmnt=/var/lib/os-prober/mount
+if [ ! -d "$tmpmnt" ]; then
+ mkdir "$tmpmnt"
+fi
+
+mounted=
+if type grub-mount >/dev/null 2>&1 && \
+ type grub-probe >/dev/null 2>&1 && \
+ grub-mount "$partition" "$tmpmnt" 2>/dev/null; then
+ mounted=1
+ type="$(grub-probe -d "$partition" -t fs)" || true
+ if [ "$type" ]; then
+ debug "mounted using GRUB $type filesystem driver"
+ else
+ debug "mounted using GRUB, but unknown filesystem?"
+ type=fuseblk
+ fi
+else
+ echo "Failed to probe $partition for filesystem type" >&2
+ exit 1
+fi
+
+if [ "$mounted" ]; then
+ for test in /usr/lib/os-probes/mounted/*; do
+ debug "running subtest $test"
+ if [ -f "$test" ] && [ -x "$test" ]; then
+ if "$test" "$partition" "$tmpmnt" "$type"; then
+ debug "os found by subtest $test"
+ if ! umount "$tmpmnt"; then
+ warn "failed to umount $tmpmnt"
+ fi
+ case "$type" in
+ btrfs)
+ # umount to account for the bind-mount
+ if [ -x "$tmpmnt/@/lib" ] && \
+ ! umount $tmpmnt; then
+ warn "failed to umount $tmpmnt"
+ fi
+ ;;
+ esac
+ rmdir "$tmpmnt" || true
+ exit 0
+ fi
+ fi
+ done
+ if ! umount "$tmpmnt"; then
+ warn "failed to umount $tmpmnt"
+ fi
+fi
+
+rmdir "$tmpmnt" || true
+
+# No tests found anything.
+exit 1
diff --git a/client/shared/lib/os-probes/init/10filesystems b/client/shared/lib/os-probes/init/10filesystems
new file mode 100755
index 00000000..f50e55ed
--- /dev/null
+++ b/client/shared/lib/os-probes/init/10filesystems
@@ -0,0 +1,39 @@
+#!/bin/sh
+# Make sure filesystems are available.
+set +e # ignore errors from modprobe
+
+FILESYSTEMS='ext2 ext3 ext4 xfs jfs msdos vfat ntfs minix hfs hfsplus qnx4 ufs btrfs'
+# fuse is needed to make grub-mount work.
+FILESYSTEMS="$FILESYSTEMS fuse"
+# The Ubuntu kernel udebs put a number of filesystem modules in
+# fs-{core,secondary}-modules. It's fairly cheap to check for these too.
+FILESYSTEMS="$FILESYSTEMS fs-core fs-secondary"
+
+if [ ! -e /var/lib/os-prober/modules ]; then
+ # Check for anna-install to make it easier to use os-prober outside
+ # d-i.
+ if type anna-install >/dev/null 2>&1 && [ -d /lib/debian-installer ]; then
+ for fs in $FILESYSTEMS; do
+ ANNA_QUIET=1 DEBIAN_FRONTEND=none \
+ log-output -t os-prober \
+ anna-install "$fs-modules" || true
+ done
+ depmod -a >/dev/null 2>&1 || true
+ fi
+
+ for fs in $FILESYSTEMS; do
+ case "$fs" in
+ fs-*)
+ ;;
+ *)
+ modprobe "$fs" 2>/dev/null | logger -t os-prober
+ ;;
+ esac
+ done
+
+ # We only want to keep this state inside d-i, so this is as good a
+ # check as any.
+ if type anna-install >/dev/null 2>&1 && [ -d /lib/debian-installer ]; then
+ touch /var/lib/os-prober/modules
+ fi
+fi
diff --git a/client/shared/lib/os-probes/mounted/05efi b/client/shared/lib/os-probes/mounted/05efi
new file mode 100755
index 00000000..93309ce3
--- /dev/null
+++ b/client/shared/lib/os-probes/mounted/05efi
@@ -0,0 +1,71 @@
+#!/bin/sh
+# Detects all Microsoft OSes on a collection of partitions.
+
+. /usr/share/os-prober/common.sh
+
+partition="$1"
+mpoint="$2"
+type="$3"
+
+# This file is for UEFI platform only
+if [ ! -d /sys/firmware/efi ] || [ -f /var/lib/partman/ignore_uefi ]; then
+ debug "Not on UEFI platform"
+ exit 1
+fi
+
+# Weed out stuff that doesn't apply to us
+case "$type" in
+ vfat) debug "$1 is a FAT32 partition" ;;
+ msdos) debug "$1 is a FAT16 partition" ;;
+ fat) debug "$1 is a FAT partition (mounted by GRUB)" ;;
+ *) debug "$1 is $type partition: exiting"; exit 1 ;;
+esac
+
+if type udevadm > /dev/null 2>&1; then
+ udevinfo () {
+ udevadm info "$@"
+ }
+fi
+
+if type udevinfo > /dev/null 2>&1; then
+ # Skip virtual devices
+ if udevinfo -q path -n $partition | grep -q /virtual/; then
+ debug "$1 is virtual device: exiting"
+ exit 1
+ fi
+
+ eval "$(udevinfo -q property -n "$partition" | grep -E '^ID_PART_ENTRY_(TYPE|SCHEME)=')"
+ debug "$partition partition scheme is $ID_PART_ENTRY_SCHEME"
+ debug "$partition partition type is $ID_PART_ENTRY_TYPE"
+
+ if [ -z "$ID_PART_ENTRY_TYPE" -o -z "$ID_PART_ENTRY_SCHEME" -o \
+ \( "$ID_PART_ENTRY_SCHEME" != gpt -a "$ID_PART_ENTRY_SCHEME" != msdos \) -o \
+ \( "$ID_PART_ENTRY_SCHEME" = gpt -a "$ID_PART_ENTRY_TYPE" != c12a7328-f81f-11d2-ba4b-00a0c93ec93b \) -o \
+ \( "$ID_PART_ENTRY_SCHEME" = msdos -a "$ID_PART_ENTRY_TYPE" != 0xef \) ]; then
+ debug "$partition is not a ESP partition: exiting"
+ exit 1
+ fi
+else
+ debug "udevinfo and udevadm missing - cannot check partition type"
+fi
+
+efi=$(item_in_dir efi "$mpoint")
+if [ -z "$efi" ]; then
+ debug "$mpoint does not have /EFI directory: exiting"
+ exit 1
+fi
+
+ret=1
+for test in /usr/lib/os-probes/mounted/efi/*; do
+ debug "running subtest $test"
+ if [ -f "$test" ] && [ -x "$test" ]; then
+ entry=$("$test" "$mpoint/$efi")
+ if [ -n "$entry" ]; then
+ debug "bootloader $entry found by subtest $test"
+ ret=0
+ result "${partition}@/$efi/${entry}:efi"
+ fi
+ fi
+done
+
+exit $ret
diff --git a/client/shared/lib/os-probes/mounted/10freedos b/client/shared/lib/os-probes/mounted/10freedos
new file mode 100755
index 00000000..94388f30
--- /dev/null
+++ b/client/shared/lib/os-probes/mounted/10freedos
@@ -0,0 +1,23 @@
+#!/bin/sh
+
+. /usr/share/os-prober/common.sh
+
+partition="$1"
+mpoint="$2"
+type="$3"
+
+# Weed out stuff that doesn't apply to us
+case "$type" in
+ vfat) debug "$1 is a FAT32 partition" ;;
+ msdos) debug "$1 is a FAT16 partition" ;;
+ fat) debug "$1 is a FAT partition (mounted by GRUB)" ;;
+ *) debug "$1 is not a FAT partition: exiting"; exit 1 ;;
+esac
+
+if item_in_dir -q kernel.sys "$2" && item_in_dir -q command.com "$2"; then
+ label="$(count_next_label FreeDOS)"
+ result "$1:FreeDOS:$label:chain"
+ exit 0
+else
+ exit 1
+fi
diff --git a/client/shared/lib/os-probes/mounted/10qnx b/client/shared/lib/os-probes/mounted/10qnx
new file mode 100755
index 00000000..8d40398f
--- /dev/null
+++ b/client/shared/lib/os-probes/mounted/10qnx
@@ -0,0 +1,21 @@
+#!/bin/sh
+
+. /usr/share/os-prober/common.sh
+
+partition="$1"
+mpoint="$2"
+type="$3"
+
+# Weed out stuff that doesn't apply to us
+case "$type" in
+ qnx4) debug "$partition is a QNX4 partition" ;;
+ *) debug "$partition is not a QNX4 partition: exiting"; exit 1 ;;
+esac
+
+if [ -e "$mpoint/.boot" ]; then
+ label="$(count_next_label QNX)"
+ result "$partition:QNX:$label:chain"
+ exit 0
+else
+ exit 1
+fi
diff --git a/client/shared/lib/os-probes/mounted/20macosx b/client/shared/lib/os-probes/mounted/20macosx
new file mode 100755
index 00000000..dd4207fe
--- /dev/null
+++ b/client/shared/lib/os-probes/mounted/20macosx
@@ -0,0 +1,30 @@
+#!/bin/sh -e
+# Detects Mac OS X. I don't yet know how Mac OS <= 9 fits into this.
+. /usr/share/os-prober/common.sh
+
+partition="$1"
+mpoint="$2"
+type="$3"
+
+debug() {
+ logger -t macosx-prober "debug: $@"
+}
+
+# Weed out stuff that doesn't apply to us
+case "$type" in
+ hfsplus) debug "$1 is an HFS+ partition" ;;
+ *) debug "$1 is not an HFS+ partition: exiting"; exit 1 ;;
+esac
+
+# Could use a better test than this.
+# /System/Library/CoreServices/SystemVersion.plist has version information,
+# but I don't think it exists on Mac OS <= 9, and it's XML so parsing in
+# shell will be nasty.
+
+if [ -e "$2/mach_kernel" ]; then
+ label="$(count_next_label MacOSX)"
+ result "$1:Mac OS X:$label:macosx"
+ exit 0
+else
+ exit 1
+fi
diff --git a/client/shared/lib/os-probes/mounted/20microsoft b/client/shared/lib/os-probes/mounted/20microsoft
new file mode 100755
index 00000000..65b38bfe
--- /dev/null
+++ b/client/shared/lib/os-probes/mounted/20microsoft
@@ -0,0 +1,140 @@
+#!/bin/sh
+# Detects all Microsoft OSes on a collection of partitions.
+
+. /usr/share/os-prober/common.sh
+
+partition="$1"
+mpoint="$2"
+type="$3"
+
+# This script looks for legacy BIOS bootloaders only. Skip if running UEFI
+if [ -d /sys/firmware/efi ] && [ ! -f /var/lib/partman/ignore_uefi ] && [ -z "$WINOSDATA" ]; then
+ debug "Skipping legacy bootloaders on UEFI system"
+ exit 1
+fi
+
+# Weed out stuff that doesn't apply to us
+case "$type" in
+ ntfs|ntfs-3g) debug "$1 is a NTFS partition" ;;
+ vfat) debug "$1 is a FAT32 partition" ;;
+ msdos) debug "$1 is a FAT16 partition" ;;
+ fat) debug "$1 is a FAT partition (mounted by GRUB)" ;;
+ fuse|fuseblk) debug "$1 is a FUSE partition" ;; # might be ntfs-3g
+ *) debug "$1 is not a MS partition: exiting"; exit 1 ;;
+esac
+
+found=
+# Vista (previously Longhorn)
+if item_in_dir -q bootmgr "$2"; then
+ # there might be different boot directories in different case as:
+ # boot Boot BOOT
+ for boot in $(item_in_dir boot "$2"); do
+ bcd=$(item_in_dir bcd "$2/$boot")
+ if [ -n "$bcd" ]; then
+ if grep -aqs "W.i.n.d.o.w.s. .1.0" "$2/$boot/$bcd"; then
+ long="Windows 10 (loader)"
+ elif grep -aqs "W.i.n.d.o.w.s. .8" "$2/$boot/$bcd"; then
+ long="Windows 8 (loader)"
+ elif grep -aqs "W.i.n.d.o.w.s. .7" "$2/$boot/$bcd"; then
+ long="Windows 7 (loader)"
+ elif grep -aqs "W.i.n.d.o.w.s. .V.i.s.t.a" "$2/$boot/$bcd"; then
+ long="Windows Vista (loader)"
+ elif grep -aqs "W.i.n.d.o.w.s. .S.e.r.v.e.r. .2.0.0.8. .R.2." "$2/$boot/$bcd"; then
+ long="Windows Server 2008 R2 (loader)"
+ elif grep -aqs "W.i.n.d.o.w.s. .S.e.r.v.e.r. .2.0.0.8." "$2/$boot/$bcd"; then
+ long="Windows Server 2008 (loader)"
+ elif grep -aqs "W.i.n.d.o.w.s. .R.e.c.o.v.e.r.y. .E.n.v.i.r.o.n.m.e.n.t" "$2/$boot/$bcd"; then
+ long="Windows Recovery Environment (loader)"
+ elif grep -aqs "W.i.n.d.o.w.s. .S.e.t.u.p" "$2/$boot/$bcd"; then
+ long="Windows Recovery Environment (loader)"
+ else
+ long="Windows Vista (loader)"
+ fi
+ short=Windows
+
+ found=true
+
+ break
+ fi
+ done
+fi
+
+# 2000/XP/NT4.0
+if [ -z "$found" ] && item_in_dir -q ntldr "$2" && item_in_dir -q ntdetect.com "$2"; then
+ long="Windows NT/2000/XP"
+ short=Windows
+ ini=$(item_in_dir boot.ini "$2")
+ if [ -n "$ini" ]; then
+ multicount="$(grep -e "^multi" "$2/$ini" | wc -l)"
+ scsicount="$(grep -e "^scsi" "$2/$ini" | wc -l)"
+ msoscount="$(expr "${multicount}" + "${scsicount}")"
+ if [ "$msoscount" -eq 1 ]; then
+ # We need to remove a Carriage Return at the end of
+ # the line...
+ defaultmspart="$(grep -e "^default=" "$2/$ini" | cut -d '=' -f2 | tr -d '\r')"
+ # Escape any backslashes in defaultmspart
+ grepexp="^$(echo "$defaultmspart" | sed -e 's/\\/\\\\/')="
+ # Colons not allowed; replace by spaces
+ # Accented characters (non UTF-8) cause debconf to
+ # hang, so we fall back to the default if the name
+ # contains any weird characters.
+ long="$(grep -e "$grepexp" "$2/$ini" | cut -d '"' -f2 | \
+ tr ':' ' ' | LC_ALL=C grep -v '[^a-zA-Z0-9 &()/_-]')"
+ if [ -z "$long" ]; then
+ long="Windows NT/2000/XP"
+ fi
+ else
+ long="Windows NT/2000/XP (loader)"
+ fi
+
+ found=true
+ fi
+fi
+
+# MS-DOS
+if [ -z "$found" ] && item_in_dir -q dos "$2"; then
+ long="MS-DOS 5.x/6.x/Win3.1"
+ short=MS-DOS
+
+ found=true
+fi
+
+# 95/98/Me
+if [ -z "$found" ] && item_in_dir -q windows "$2" &&
+ item_in_dir -q win.com "$2"/"$(item_in_dir windows "$2")"; then
+ long="Windows 95/98/Me"
+ short=Windows9xMe
+
+ found=true
+fi
+
+
+# Restrict to partitions containing the OS
+if [ -n "$WINOSDATA" ]; then
+ found=
+ if [ -d "$2/ProgramData/Microsoft/Windows/Start Menu/Programs/StartUp" ]; then
+ long=${long:-"Windows 8 (data)"}
+ short=${short:-"Windows"}
+ found=true
+ elif [ -d "$2/ProgramData/Microsoft/Windows/Start Menu/Programs/Startup" ]; then
+ long=${long:-"Windows 7 (data)"}
+ short=${short:-"Windows"}
+ found=true
+ elif [ -d "$2/Documents and Settings/All Users/Start Menu/Programs/Startup" ]; then
+ long=${long:-"Windows XP/Vista (data)"}
+ short=${short:-"Windows"}
+ found=true
+ elif [ -d "$2/Winnt/Profiles/All Users/Start Menu/Programs/Startup" ]; then
+ long=${long:-"Windows NT (data)"}
+ short=${short:-"Windows"}
+ found=true
+ fi
+fi
+
+if [ -z "$found" ]; then
+ exit 1
+fi
+
+label="$(count_next_label "$short")"
+result "${partition}:${long}:${label}:chain"
+exit 0
diff --git a/client/shared/lib/os-probes/mounted/30utility b/client/shared/lib/os-probes/mounted/30utility
new file mode 100755
index 00000000..af48d307
--- /dev/null
+++ b/client/shared/lib/os-probes/mounted/30utility
@@ -0,0 +1,33 @@
+#!/bin/sh
+# Detects utility (hw vendor recovery) partitions.
+
+. /usr/share/os-prober/common.sh
+
+partition="$1"
+mpoint="$2"
+type="$3"
+
+# Weed out stuff that doesn't apply to us
+case "$type" in
+ vfat) debug "$1 is a FAT32 partition" ;;
+ msdos) debug "$1 is a FAT16 partition" ;;
+ fat) debug "$1 is a FAT partition (mounted by GRUB)" ;;
+ *) debug "$1 is not a FAT partition: exiting"; exit 1 ;;
+esac
+
+# Dell Utility partitions have partition type 0xde, but no idea how to
+# cleanly detect that from shell
+if item_in_dir -q dellbio.bin "$2" && \
+ (item_in_dir -q delldiag.exe "$2" || item_in_dir -q delldiag.com "$2"); then
+ long="Dell Utility Partition"
+ short=DellUtility
+elif item_in_dir -q f11.sys "$2"; then
+ long="Acronis Secure Zone"
+ short=AcroneZone
+else
+ exit 1
+fi
+
+label="$(count_next_label "$short")"
+result "${partition}:${long}:${label}:chain"
+exit 0
diff --git a/client/shared/lib/os-probes/mounted/40lsb b/client/shared/lib/os-probes/mounted/40lsb
new file mode 100755
index 00000000..ce8d4e1f
--- /dev/null
+++ b/client/shared/lib/os-probes/mounted/40lsb
@@ -0,0 +1,48 @@
+#!/bin/sh
+# Test for LSB systems.
+set -e
+
+. /usr/share/os-prober/common.sh
+
+partition="$1"
+dir="$2"
+type="$3"
+
+lsb_field () {
+ file="$1"
+ field="$2"
+ grep ^"$field" "$file" | cut -d = -f 2 | sed 's/^"//' | sed 's/"$//' | sed 's/:/ /g'
+}
+
+file="$dir/etc/lsb-release"
+if [ ! -e "$file" ]; then
+ exit 1
+fi
+
+release=$(lsb_field "$file" DISTRIB_RELEASE)
+if [ -z "$release" ]; then
+ release=$(lsb_field "$file" DISTRIB_CODENAME)
+fi
+description=$(lsb_field "$file" DISTRIB_DESCRIPTION)
+if [ -z "$description" ]; then
+ description=$(lsb_field "$file" DISTRIB_CODENAME)
+fi
+
+if [ -n "$description" ]; then
+ if [ -n "$release" ]; then
+ long="$description ($release)"
+ else
+ long="$description"
+ fi
+else
+ exit 1
+fi
+
+short=$(lsb_field "$file" DISTRIB_ID | sed 's/ //g')
+if [ -z "$short" ]; then
+ short="UnknownLSB"
+fi
+
+label="$(count_next_label "$short")"
+result "$partition:$long:$label:linux"
+exit 0
diff --git a/client/shared/lib/os-probes/mounted/70hurd b/client/shared/lib/os-probes/mounted/70hurd
new file mode 100755
index 00000000..af29ff55
--- /dev/null
+++ b/client/shared/lib/os-probes/mounted/70hurd
@@ -0,0 +1,16 @@
+#!/bin/sh
+set -e
+
+. /usr/share/os-prober/common.sh
+
+partition="$1"
+dir="$2"
+type="$3"
+
+if [ -d "$dir/servers" ] && [ -d "$dir/hurd" ]; then
+ label="$(count_next_label Hurd)"
+ result "$partition:GNU/Hurd:$label:hurd"
+ exit 0
+else
+ exit 1
+fi
diff --git a/client/shared/lib/os-probes/mounted/80minix b/client/shared/lib/os-probes/mounted/80minix
new file mode 100755
index 00000000..e01f6695
--- /dev/null
+++ b/client/shared/lib/os-probes/mounted/80minix
@@ -0,0 +1,28 @@
+#!/bin/sh
+set -e
+
+. /usr/share/os-prober/common.sh
+
+partition="$1"
+dir="$2"
+type="$3"
+
+# Weed out stuff that doesn't apply to us
+case "$type" in
+ minix|minix2|ext2) ;;
+ *) exit 1 ;;
+esac
+
+if [ -f "$dir/minix" ] || [ -e "$dir/boot/image_big" ]; then
+ if [ -e "$dir/boot/image_latest" ]; then
+ boot="minix"
+ else
+ boot="chain"
+ fi
+
+ label="$(count_next_label Minix)"
+ result "$partition:Minix:$label:$boot"
+ exit 0
+else
+ exit 1
+fi
diff --git a/client/shared/lib/os-probes/mounted/83haiku b/client/shared/lib/os-probes/mounted/83haiku
new file mode 100755
index 00000000..6de7a1d4
--- /dev/null
+++ b/client/shared/lib/os-probes/mounted/83haiku
@@ -0,0 +1,35 @@
+#!/bin/sh
+# Detects Haiku on BeFS partitions.
+
+. /usr/share/os-prober/common.sh
+
+partition="$1"
+mpoint="$2"
+type="$3"
+
+# Weed out stuff that doesn't apply to us
+case "$type" in
+ befs|befs_be) debug "$partition is a BeFS partition" ;;
+ *) debug "$partition is not a BeFS partition: exiting"; exit 1 ;;
+esac
+
+if head -c 512 "$partition" | grep -qs "system.haiku_loader"; then
+ debug "Stage 1 bootloader found"
+else
+ debug "Stage 1 bootloader not found: exiting"
+ exit 1
+fi
+
+if system="$(item_in_dir "system" "$mpoint")" &&
+ item_in_dir -q "haiku_loader" "$mpoint/$system" &&
+ (item_in_dir -q "kernel_x86" "$mpoint/$system" ||
+ item_in_dir -q "kernel_x86_64" "$mpoint/$system")
+then
+ debug "Stage 2 bootloader and kernel found"
+ label="$(count_next_label Haiku)"
+ result "$partition:Haiku:$label:chain"
+ exit 0
+else
+ debug "Stage 2 bootloader and kernel not found: exiting"
+ exit 1
+fi
diff --git a/client/shared/lib/os-probes/mounted/90linux-distro b/client/shared/lib/os-probes/mounted/90linux-distro
new file mode 100755
index 00000000..6678f22e
--- /dev/null
+++ b/client/shared/lib/os-probes/mounted/90linux-distro
@@ -0,0 +1,138 @@
+#!/bin/sh
+# Test for linux distributions.
+set -e
+
+. /usr/share/os-prober/common.sh
+
+partition="$1"
+dir="$2"
+type="$3"
+
+# This test is inaccurate, but given separate / and /boot partitions and the
+# fact that only some architectures have ld-linux.so, I can't see anything
+# better. Make sure this test has a high number so that more accurate tests
+# can come first.
+# Unless volumes to checked are already mounted, they will be mounted using
+# GRUB's own filesystems through FUSE. Since these ATM doesn't support
+# symlinks we need to also check in $dir/usr/lib* for distributions that
+# moved /lib* to /usr and only left symlinks behind.
+# TODO: look for ld-linux.so on arches that have it
+if (ls "$dir"/lib*/ld*.so* || ls "$dir"/usr/lib*/ld*.so*) >/dev/null 2>/dev/null; then
+ if [ -e "$dir/etc/debian_version" ]; then
+ short="Debian"
+ long="$(printf "Debian GNU/Linux (%s)\n" "$(cat "$dir/etc/debian_version")")"
+ # RPM derived distributions may also have a redhat-release or
+ # mandrake-release, so check their files first.
+ elif [ -e "$dir/etc/altlinux-release" ]; then
+ short="ALTLinux"
+ long="$(cat "$dir/etc/altlinux-release")"
+ elif [ -e "$dir/etc/magic-release" ]; then
+ short="Magic"
+ long="$(cat "$dir/etc/magic-release")"
+ elif [ -e "$dir/etc/blackPanther-release" ]; then
+ short="blackPanther"
+ long="$(cat "$dir/etc/blackPanther-release")"
+ elif [ -e "$dir/etc/ark-release" ]; then
+ short="Ark"
+ long="$(cat "$dir/etc/ark-release")"
+ elif [ -e "$dir/etc/arch-release" ]; then
+ short="Arch"
+ long="$(cat "$dir/etc/arch-release")"
+ elif [ -e "$dir/etc/asplinux-release" ]; then
+ short="ASPLinux"
+ long="$(cat "$dir/etc/asplinux-release")"
+ elif [ -e "$dir/etc/lvr-release" ]; then
+ short="LvR"
+ long="$(cat "$dir/etc/lvr-release")"
+ elif [ -e "$dir/etc/caos-release" ]; then
+ short="cAos"
+ long="$(cat "$dir/etc/caos-release")"
+ elif [ -e "$dir/etc/aurox-release" ]; then
+ short="Aurox"
+ long="$(cat "$dir/etc/aurox-release")"
+ elif [ -e "$dir/etc/engarde-release" ]; then
+ short="EnGarde"
+ long="$(cat "$dir/etc/engarde-release")"
+ elif [ -e "$dir/etc/vine-release" ]; then
+ short="Vine"
+ long="$(cat "$dir/etc/vine-release")"
+ elif [ -e "$dir/etc/whitebox-release" ]; then
+ short="WhiteBox"
+ long="$(cat "$dir/etc/whitebox-release")"
+ elif [ -e "$dir/etc/pld-release" ]; then
+ short="PLD"
+ long="$(cat "$dir/etc/pld-release")"
+ elif [ -e "$dir/etc/startcom-release" ]; then
+ short="StartCom"
+ long="$(cat "$dir/etc/startcom-release")"
+ elif [ -e "$dir/etc/trustix-release" ]; then
+ short="Trustix"
+ long="$(cat "$dir/etc/trustix-release")"
+ elif [ -e "$dir/etc/openna-release" ]; then
+ short="OpenNA"
+ long="$(cat "$dir/etc/openna-release")"
+ elif [ -e "$dir/etc/conectiva-release" ]; then
+ short="Conectiva"
+ long="$(cat "$dir/etc/conectiva-release")"
+ elif [ -e "$dir/etc/mandrake-release" ]; then
+ short="Mandrake"
+ long="$(cat "$dir/etc/mandrake-release")"
+ elif [ -e "$dir/etc/fedora-release" ]; then
+ short="Fedora"
+ long="$(cat "$dir/etc/fedora-release")"
+ elif [ -e "$dir/etc/redhat-release" ]; then
+ short="RedHat"
+ long="$(cat "$dir/etc/redhat-release")"
+ elif [ -e "$dir/etc/SuSE-release" ]; then
+ short="SuSE"
+ long="$(head -n 1 "$dir/etc/SuSE-release")"
+ elif [ -e "$dir/etc/gentoo-release" ]; then
+ short="Gentoo"
+ long="$(cat "$dir/etc/gentoo-release")"
+ elif [ -e "$dir/etc/cobalt-release" ]; then
+ short="Cobalt"
+ long="$(cat "$dir/etc/cobalt-release")"
+ elif [ -e "$dir/etc/yellowdog-release" ]; then
+ short="YellowDog"
+ long="$(cat "$dir/etc/yellowdog-release")"
+ elif [ -e "$dir/etc/turbolinux-release" ]; then
+ short="Turbolinux"
+ long="$(cat "$dir/etc/turbolinux-release")"
+ elif [ -e "$dir/etc/pardus-release" ]; then
+ short="Pardus"
+ long="$(cat "$dir/etc/pardus-release")"
+ elif [ -e "$dir/etc/kanotix-version" ]; then
+ short="Kanotix"
+ long="$(cat "$dir/etc/kanotix-version")"
+ elif [ -e "$dir/etc/slackware-version" ]; then
+ short="Slackware"
+ long="$(printf "Slackware Linux (%s)\n" "$(cat "$dir/etc/slackware-version")")"
+ elif [ -e "$dir/sbin/pkgtool" ]; then
+ short="Slackware"
+ long="Slackware Linux"
+ elif grep -qs OpenLinux "$dir/etc/issue"; then
+ short="Caldera"
+ long="Caldera OpenLinux"
+ elif [ -e "$dir/etc/frugalware-release" ]; then
+ short="Frugalware Linux"
+ long="$(cat "$dir/etc/frugalware-release")"
+ elif [ -e "$dir/etc/kdemar-release" ]; then
+ short="K-DEMar"
+ long="$(printf "K-DEMar GNU/Linux (%s)\n" "$(cat "$dir/etc/kdemar-release")")"
+ elif [ -e "$dir/etc/lfs-release" ]; then
+ short="LFS"
+ long="$(printf "Linux From Scratch (%s)\n" "$(cat "$dir/etc/lfs-release")")"
+ elif [ -e "$dir/etc/meego-release" ]; then
+ short="MeeGo"
+ long="$(head -1 "$dir/etc/meego-release")"
+ else
+ short="Linux"
+ long="unknown Linux distribution"
+ fi
+
+ label="$(count_next_label "$short")"
+ result "$partition:$long:$label:linux"
+ exit 0
+else
+ exit 1
+fi
diff --git a/client/shared/lib/os-probes/mounted/90solaris b/client/shared/lib/os-probes/mounted/90solaris
new file mode 100755
index 00000000..0e9148ce
--- /dev/null
+++ b/client/shared/lib/os-probes/mounted/90solaris
@@ -0,0 +1,19 @@
+#!/bin/sh
+# Attempt to check if solaris is installed in this system
+# looking at the /etc/system parameters file and /etc/vfstab.
+
+set -e
+
+. /usr/share/os-prober/common.sh
+
+partition="$1"
+dir="$2"
+type="$3"
+
+if [ -f "$dir/etc/system" ] && [ -f "$dir/etc/vfstab" ]; then
+ label="$(count_next_label Solaris)"
+ result "$partition:Solaris/IA32:$label:chain"
+ exit 0
+else
+ exit 1
+fi
diff --git a/client/shared/lib/os-probes/mounted/efi/10elilo b/client/shared/lib/os-probes/mounted/efi/10elilo
new file mode 100755
index 00000000..72dc4627
--- /dev/null
+++ b/client/shared/lib/os-probes/mounted/efi/10elilo
@@ -0,0 +1,24 @@
+#!/bin/sh
+# Detects ELILO bootloader on a EFI System Partition
+
+. /usr/share/os-prober/common.sh
+
+efi="$1"
+
+found=
+
+elilo=`find $1 -name "elilo.efi"`
+if [ -n "$elilo" ]; then
+ bdir=`dirname $elilo`
+ bdir=`basename $bdir`
+ long="ELILO Boot Manager"
+ short="ELILO"
+ path=${bdir}/elilo.efi
+ found=true
+fi
+
+if [ -n "$found" ]; then
+ label="$(count_next_label "$short")"
+ result "${path}:${long}:${label}"
+fi
+exit 0
diff --git a/client/shared/lib/os-probes/mounted/efi/20microsoft b/client/shared/lib/os-probes/mounted/efi/20microsoft
new file mode 100755
index 00000000..95320814
--- /dev/null
+++ b/client/shared/lib/os-probes/mounted/efi/20microsoft
@@ -0,0 +1,28 @@
+#!/bin/sh
+# Detects Microsoft bootloader on a EFI System Partition
+
+. /usr/share/os-prober/common.sh
+
+efi="$1"
+
+found=
+for microsoft in $(item_in_dir microsoft "$efi"); do
+ for boot in $(item_in_dir boot "$efi/$microsoft"); do
+ bcd=$(item_in_dir bcd "$efi/$microsoft/$boot")
+ bootmgfw=$(item_in_dir bootmgfw.efi "$efi/$microsoft/$boot")
+ if [ -n "$bcd" -a -n "$bootmgfw" ]; then
+ long="Windows Boot Manager"
+ short=Windows
+ path="$microsoft/$boot/$bootmgfw"
+ found=true
+ break
+ fi
+ done
+done
+
+
+if [ -n "$found" ]; then
+ label="$(count_next_label "$short")"
+ result "${path}:${long}:${label}"
+fi
+exit 0