#!/bin/sh
# Detects all Microsoft OSes on a collection of 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
  ntfs) debug "$1 is a NTFS partition" ;;
  vfat) debug "$1 is a FAT32 partition" ;;
  msdos) debug "$1 is a FAT16 partition" ;;
  *) debug "$1 is not a MS partition: exiting"; exit 1 ;;
esac

# 2000/XP/NT4.0
if [ -e "$2/ntldr" -a -e "$2/NTDETECT.COM" ]; then
  long="Windows NT/2000/XP"
  short=Windows
# MS-DOS
elif [ -d "$2/dos" ]; then
  long="MS-DOS 5.x/6.x/Win3.1"
  short=MS-DOS
# 95/98/Me
elif [ -e "$2/windows/win.com" ]; then
  long="Windows 95/98/Me"
  short=Windows9xMe
else
  exit 1
fi

label=$(count_next_label $short)
result "${partition}:${long}:${short}:chain"
