# define FLOPPY_MAJOR 2
#endif
+#if defined (__sun__)
+# include <sys/dkio.h>
+#endif
+
#if defined(__APPLE__)
# include <sys/disk.h>
#endif
grub_uint64_t
grub_util_get_fd_sectors (int fd, unsigned *log_secsize)
{
-#if defined(__linux__) || defined(__CYGWIN__) || defined(__FreeBSD__) || \
- defined(__FreeBSD_kernel__) || defined(__APPLE__) || defined(__NetBSD__)
# if defined(__NetBSD__)
struct disklabel label;
-# else
+# elif defined (__sun__)
+ struct dk_minfo minfo;
+#else
unsigned long long nr;
# endif
unsigned sector_size, log_sector_size;
if (fstat (fd, &st) < 0)
grub_util_error ("fstat failed");
-# if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__APPLE__) || defined(__NetBSD__)
+#if defined(__linux__) || defined(__CYGWIN__) || defined(__FreeBSD__) || \
+ defined(__FreeBSD_kernel__) || defined(__APPLE__) || defined(__NetBSD__) \
+ || defined (__sun__)
+
+# if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__APPLE__) || defined(__NetBSD__) || defined (__sun__)
if (! S_ISCHR (st.st_mode))
# else
if (! S_ISBLK (st.st_mode))
# elif defined(__NetBSD__)
configure_device_driver (fd);
if (ioctl (fd, DIOCGDINFO, &label) == -1)
+# elif defined (__sun__)
+ if (!ioctl (fd, DKIOCGMEDIAINFO, &minfo))
# else
if (ioctl (fd, BLKGETSIZE64, &nr))
# endif
# if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
if (ioctl (fd, DIOCGSECTORSIZE, §or_size))
goto fail;
+# elif defined(__sun__)
+ sector_size = minfo.dki_lbsize;
# elif defined(__NetBSD__)
sector_size = label.d_secsize;
# else
if (ioctl (fd, BLKSSZGET, §or_size))
goto fail;
# endif
-
if (sector_size & (sector_size - 1) || !sector_size)
goto fail;
for (log_sector_size = 0;
return nr;
# elif defined(__NetBSD__)
return label.d_secperunit;
+# elif defined (__sun__)
+ return minfo.dki_capacity;
# else
if (nr & ((1 << log_sector_size) - 1))
grub_util_error ("unaligned device size");
# endif
fail:
+
/* In GNU/Hurd, stat() will return the right size. */
#elif !defined (__GNU__)
# warning "No special routine to get the size of a block device is implemented for your OS. This is not possibly fatal."
#endif
+ sector_size = 512;
+ log_sector_size = 9;
+
if (log_secsize)
*log_secsize = 9;
return out;
}
-#elif defined(__linux__) || defined(__CYGWIN__) || defined(HAVE_DIOCGDINFO)
+#elif defined(__linux__) || defined(__CYGWIN__) || defined(HAVE_DIOCGDINFO) || defined (__sun__)
static grub_disk_addr_t
find_partition_start (const char *dev)
{
int fd;
-# if !defined(HAVE_DIOCGDINFO)
+#ifdef __sun__
+ struct extpart_info pinfo;
+# elif !defined(HAVE_DIOCGDINFO)
struct hd_geometry hdg;
# else /* defined(HAVE_DIOCGDINFO) */
struct disklabel label;
return 0;
}
-# if !defined(HAVE_DIOCGDINFO)
+#if defined(__sun__)
+ if (ioctl (fd, DKIOCEXTPARTINFO, &pinfo))
+# elif !defined(HAVE_DIOCGDINFO)
if (ioctl (fd, HDIO_GETGEO, &hdg))
# else /* defined(HAVE_DIOCGDINFO) */
# if defined(__NetBSD__)
close (fd);
-# if !defined(HAVE_DIOCGDINFO)
+#ifdef __sun__
+ return pinfo.p_start;
+# elif !defined(HAVE_DIOCGDINFO)
return hdg.start;
# else /* defined(HAVE_DIOCGDINFO) */
if (dev[0])
}
return path;
+#elif defined (__sun__)
+ char *colon = grub_strrchr (os_dev, ':');
+ if (grub_memcmp (os_dev, "/devices", sizeof ("/devices") - 1) == 0
+ && colon)
+ {
+ char *ret = xmalloc (colon - os_dev + sizeof (":q,raw"));
+ grub_memcpy (ret, os_dev, colon - os_dev);
+ grub_memcpy (ret + (colon - os_dev), ":q,raw", sizeof (":q,raw"));
+ return ret;
+ }
+ else
+ return xstrdup (os_dev);
#else
# warning "The function `convert_system_partition_to_system_disk' might not work on your OS correctly."
return xstrdup (os_dev);
#endif
}
+#if defined(__sun__)
+static int
+device_is_wholedisk (const char *os_dev)
+{
+ if (grub_memcmp (os_dev, "/devices/", sizeof ("/devices/") - 1) != 0)
+ return 1;
+ if (grub_memcmp (os_dev + strlen (os_dev) - (sizeof (":q,raw") - 1),
+ ":q,raw", (sizeof (":q,raw") - 1)) == 0)
+ return 1;
+ return 0;
+}
+#endif
+
#if defined(__linux__) || defined(__CYGWIN__)
static int
device_is_wholedisk (const char *os_dev)
convert_system_partition_to_system_disk (os_dev, &st)) == 0)
return make_device_name (drive, -1, -1);
-#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__APPLE__) || defined(__NetBSD__)
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__APPLE__) || defined(__NetBSD__) || defined (__sun__)
if (! S_ISCHR (st.st_mode))
#else
if (! S_ISBLK (st.st_mode))
#endif
return make_device_name (drive, -1, -1);
-#if defined(__linux__) || defined(__CYGWIN__) || defined(HAVE_DIOCGDINFO) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
+#if defined(__linux__) || defined(__CYGWIN__) || defined(HAVE_DIOCGDINFO) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined (__sun__)
/* Linux counts partitions uniformly, whether a BSD partition or a DOS
partition, so mapping them to GRUB devices is not trivial.
name = make_device_name (drive, -1, -1);
-# if !defined(HAVE_DIOCGDINFO)
+# if !defined(HAVE_DIOCGDINFO) && !defined(__sun__)
if (MAJOR (st.st_rdev) == FLOPPY_MAJOR)
return name;
# else /* defined(HAVE_DIOCGDINFO) */
--- /dev/null
+#! /bin/sh
+set -e
+
+# grub-mkconfig helper script.
+# Copyright (C) 2006,2007,2008,2009,2010,2011 Free Software Foundation, Inc.
+#
+# GRUB is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# GRUB is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+bindir=@bindir@
+libdir=@libdir@
+datarootdir=@datarootdir@
+. ${libdir}/@PACKAGE@/grub-mkconfig_lib
+
+export TEXTDOMAIN=@PACKAGE@
+export TEXTDOMAINDIR=@localedir@
+
+CLASS="--class os"
+
+case "${GRUB_DISTRIBUTOR}" in
+ *)
+ OS="Illumos"
+ CLASS="--class illumos ${CLASS}"
+ ;;
+esac
+
+echo "menuentry '${OS}' ${CLASS} {"
+save_default_entry | sed -e "s/^/\t/"
+prepare_grub_to_access_device ${GRUB_DEVICE_BOOT} | sed -e "s/^/\t/"
+message="$(gettext_printf "Loading kernel of Illumos ...")"
+ cat << EOF
+ insmod gzio
+ if cpuid -l ; then
+ ISADIR=amd64
+ else
+ ISADIR=
+ fi
+ zfs-bootfs $($grub_mkrelpath /) ZFS_BOOTFS
+ multiboot $($grub_mkrelpath /platform/i86pc/kernel)/\$ISADIR/unix /platform/i86pc/kernel/\$ISADIR/unix -B \$ZFS_BOOTFS,console=text
+ module $($grub_mkrelpath /platform/i86pc)/\$ISADIR/boot_archive /platform/i86pc/\$ISADIR/boot_archive
+}
+EOF