#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# DO NOT CHANGE THE FORMAT OF THIS SCRIPT'S OUTPUT WITHOUT ALSO CHANGING
# bootmgmt.backend.autogen.chain'S PARSING CODE!
#
# This script attempts to detect legacy OS's installed on the system and
# outputs lines that the pybootmgmt package uses to create chain loading
# directives in boot loader menus.
# Currently this is know to work for NT derived Windows systems (ntfs or
# partitions). It is likely to work for OS/2 on IFS partitions. Linux,
# particularly on extended partitions is not supported at this point. For
# every non-understood partition type that is potentially bootable a
# comment is generated that identifies its Solaris device name, the
# partition type as well as the GRUB device name to give an educated user
# as much information as possible to generate their own entry.
# generate a chainload entry for a specific OS entry
# of the form:
# <title>:<grub root>:<active>
#
{
root=$1
_partition=$2
title=$3
active=$4
}
# process a FAT partition
#
{
root=$3
part=$4
}
# process an IFS partition
#
{
dev=$1
rdev=$2
root=$3
part=$4
else
fi
}
# process a Solaris partition - this only deals with DCA based Solaris
# instances as GRUB based Solaris instances are handled directly by bootadm
#
{
dev=$1
rdev=$2
root=$3
part=$4
for i in 0 1 3 4 5 6 7 ; do
if [ $? != 0 ] ; then
continue
fi
fi
fi
fi
done
}
# process a Solaris x86-boot partition
#
{
dev=$1
rdev=$2
root=$3
part=$4
device=""
fi
return
fi
if [ $? != 0 ] ; then
continue
fi
fi
fi
fi
}
# process a diag (usually DOS based) partition
#
{
root=$3
part=$4
}
# generate a comment for an unsupported partition
#
{
disk=$1
partition=$2
root=$3
part=$4
id=$5
printf "maps to (0-based) bootable disk ${root}, "
printf "(0-based) partition ${part}."
}
# begin main
#
fi
typeset -i partition=1
typeset -i gpart
typeset -i gdisk
if [ $? = 0 ] ; then
else
gdisk=0
fi
# presence of /.cdrom/.liveusb indicates install from USB disk
# for USB installation the GRUB map will list the USB disk
# as the first device, which is very likely not the normal order
# reset the normal order by decrementing the disk index
# identify windows partitions and decrement
# disk index for USB installations
7|11|12|18|23|222)
;;
*) root="${gdisk}"
;;
esac
else
root="${gdisk}"
fi
0) ;; # unused
7) handle_ifs $dev $rdev $root $gpart ;;
11) handle_fat $dev $rdev $root $gpart ;;
12) handle_fat $dev $rdev $root $gpart ;;
18) handle_diag $dev $rdev $root $gpart ;;
23) handle_ifs $dev $rdev $root $gpart ;;
28) ;; # hidden FAT32 must ignore
130) handle_solaris $dev $rdev $root $gpart ;;
190) handle_x86boot $dev $rdev $root $gpart ;;
191) handle_solaris $dev $rdev $root $gpart ;;
222) handle_diag $dev $rdev $root $gpart ;;
238) ;; # Protective GPT - ignore
esac
done
done
exit 0