summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcel Telka <Marcel.Telka@nexenta.com>2013-07-09 11:56:37 +0200
committerRichard Lowe <richlowe@richlowe.net>2013-07-12 15:48:31 -0400
commit01f9868a8d2cedd96c3aeefbd7233aa77f7b72ff (patch)
tree9218f593673f6bca4df07d9dd5f53c7ddeb648e3
parent265b5a40862f786981e8192cb44ebb70ecc9cfc8 (diff)
downloadillumos-joyent-01f9868a8d2cedd96c3aeefbd7233aa77f7b72ff.tar.gz
3877 fast reboot does not work with extended partition
Reviewed by: Saso Kiselkov <skiselkov.ml@gmail.com> Reviewed by: Hans Rosenfeld <hans.rosenfeld@nexenta.com> Reviewed by: Dan McDonald <danmcd@nexenta.com> Approved by: Richard Lowe <richlowe@richlowe.net>
-rw-r--r--usr/src/lib/libgrubmgmt/common/libgrub_fs.c36
-rw-r--r--usr/src/lib/libgrubmgmt/common/libgrub_impl.h6
-rw-r--r--usr/src/lib/libgrubmgmt/i386/Makefile6
3 files changed, 45 insertions, 3 deletions
diff --git a/usr/src/lib/libgrubmgmt/common/libgrub_fs.c b/usr/src/lib/libgrubmgmt/common/libgrub_fs.c
index 51f7cc0e17..28a47deabb 100644
--- a/usr/src/lib/libgrubmgmt/common/libgrub_fs.c
+++ b/usr/src/lib/libgrubmgmt/common/libgrub_fs.c
@@ -22,9 +22,12 @@
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
+/*
+ * Copyright 2013 Nexenta Systems, Inc. All rights reserved.
+ */
/*
- * This file contains all the functions that manipualte the file
+ * This file contains all the functions that manipulate the file
* system where the GRUB menu resides.
*/
#include <stdio.h>
@@ -42,6 +45,9 @@
#include <sys/fs/ufs_mount.h>
#include <sys/dktp/fdisk.h>
#include <libfstyp.h>
+#if defined(i386) || defined(__amd64)
+#include <libfdisk.h>
+#endif
#include "libgrub_impl.h"
@@ -84,6 +90,10 @@ get_sol_prtnum(const char *physpath)
struct ipart *ipart;
char boot_sect[512];
char rdev[MAXNAMELEN];
+#if defined(i386) || defined(__amd64)
+ ext_part_t *epp;
+ int ext_part_found = 0;
+#endif
(void) snprintf(rdev, sizeof (rdev), "/devices%s,raw", physpath);
@@ -105,6 +115,28 @@ get_sol_prtnum(const char *physpath)
for (i = 0; i < FD_NUMPART; ++i) {
if (ipart[i].systid == SUNIXOS || ipart[i].systid == SUNIXOS2)
return (i);
+
+#if defined(i386) || defined(__amd64)
+ if (!fdisk_is_dos_extended(ipart[i].systid) ||
+ (ext_part_found == 1))
+ continue;
+
+ ext_part_found = 1;
+
+ if (libfdisk_init(&epp, rdev, NULL, FDISK_READ_DISK) ==
+ FDISK_SUCCESS) {
+ uint32_t begs, nums;
+ int pno;
+ int rval;
+
+ rval = fdisk_get_solaris_part(epp, &pno, &begs, &nums);
+
+ libfdisk_fini(&epp);
+
+ if (rval == FDISK_SUCCESS)
+ return (pno - 1);
+ }
+#endif
}
return (PRTNUM_INVALID);
}
@@ -146,7 +178,7 @@ get_zfs_root(zfs_handle_t *zfh, grub_fs_t *fs, grub_root_t *root)
/*
* On entry physpath parameter supposed to contain:
* <disk_physpath>[<space><disk_physpath>]*.
- * Retireives first <disk_physpath> that matches both partition and slice.
+ * Retrieves first <disk_physpath> that matches both partition and slice.
* If any partition and slice is acceptable, first <disk_physpath> is returned.
*/
static int
diff --git a/usr/src/lib/libgrubmgmt/common/libgrub_impl.h b/usr/src/lib/libgrubmgmt/common/libgrub_impl.h
index 0d33400e7d..5d973b20d2 100644
--- a/usr/src/lib/libgrubmgmt/common/libgrub_impl.h
+++ b/usr/src/lib/libgrubmgmt/common/libgrub_impl.h
@@ -22,6 +22,9 @@
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
+/*
+ * Copyright 2013 Nexenta Systems, Inc. All rights reserved.
+ */
#ifndef _GRBMIMPL_H
#define _GRBMIMPL_H
@@ -34,6 +37,7 @@ extern "C" {
#include <sys/param.h>
#include <sys/mntent.h>
#include <sys/uadmin.h>
+#include <sys/dktp/fdisk.h>
#include <libzfs.h>
#include <libdevinfo.h>
#include "libgrubmgmt.h"
@@ -55,7 +59,7 @@ extern "C" {
#define SLCNUM_WHOLE_DISK 'q'
#define IS_SLCNUM_VALID(x) ((x) >= SLCNUM_FIRST && (x) < SLCNUM_WHOLE_DISK)
-#define IS_PRTNUM_VALID(x) ((uint_t)(x) < FD_NUMPART)
+#define IS_PRTNUM_VALID(x) ((uint_t)(x) < FD_NUMPART + MAX_EXT_PARTS)
#define GRBM_VALID_FLAG ((uint_t)1 << 31)
#define GRBM_MAXLINE 8192
diff --git a/usr/src/lib/libgrubmgmt/i386/Makefile b/usr/src/lib/libgrubmgmt/i386/Makefile
index 0ef5233f44..9b91a98d13 100644
--- a/usr/src/lib/libgrubmgmt/i386/Makefile
+++ b/usr/src/lib/libgrubmgmt/i386/Makefile
@@ -22,8 +22,14 @@
# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
+# Copyright 2013 Nexenta Systems, Inc. All rights reserved.
#
include ../Makefile.com
+#
+# Libraries added to the next line must be present in miniroot
+#
+LDLIBS += -lfdisk
+
install: all $(ROOTLIBS) $(ROOTLINKS) $(ROOTLINT)