Configuration of HAVE_GETRAWPARTITION for grub-probe support on NetBSD.

This commit is contained in:
Grégoire Sutre 2010-01-02 11:26:01 +00:00 committed by Thomas Klausner
parent c41a9d33ca
commit 0be4f8c7bd
3 changed files with 60 additions and 44 deletions

View file

@ -1,15 +1,14 @@
$NetBSD: distinfo,v 1.16 2010/01/02 02:01:43 gregoire Exp $
$NetBSD: distinfo,v 1.17 2010/01/02 11:26:01 gregoire Exp $
SHA1 (patch-10_linux-gettext) = fe0cfbaae7fe9ba98ceffe3ef68e25a63b0d2afd
SHA1 (patch-__enable_execute_stack) = 7fde8c41c0cbd2f718bc4cab219b8e5dc1e99c4f
SHA1 (patch-ab) = b8af0f7ee12ac44a6246786b2239efd21fd2e63a
SHA1 (patch-ac) = 4bfc5930654b68cea7687d7f30a9b78a71b7541b
SHA1 (patch-ad) = 95eaffddf037bdd26bb981fbcbb1a58f0f327622
SHA1 (patch-configure-LDFLAGS_AC) = 794ec679e40bab7d2772ba11cad46910951e7ea0
SHA1 (patch-gcc-warning-on-error-attribute) = 356c26bc6ee35019581501543e27b4637d84764e
SHA1 (patch-grub-install-mkdir) = 18d45465c18ec58380df5a6ee382a2e045ecf4de
SHA1 (patch-grub-mkconfig-grub_prefix) = 708b0792576f93a183a9c4ce262f6f8ad7eca35d
SHA1 (patch-grub-probe-netbsd) = 31424d470b0dba9723fb86ba7e9265ec81e2d34c
SHA1 (patch-grub-probe-netbsd) = 6719c5eb8f07a4a9eae14876ff2cc40e07fdd802
SHA1 (patch-macroify-DEFAULT_DIRECTORY) = c085a748ab7b5ace6e0818be105cbf31d6f6440e
SHA1 (patch-makefile-gcc-headers) = c8bedfe1301d63959270f69624e1bf9ff53842b9
SHA1 (patch-misc-realpath) = efa6c81c725138ce72c539e9650302aa2c0bc8c3

View file

@ -1,17 +0,0 @@
$NetBSD: patch-ab,v 1.1.1.1 2009/12/21 17:41:00 gregoire Exp $
--- configure.ac.orig 2009-12-21 12:02:48.000000000 +0100
+++ configure.ac
@@ -530,6 +530,12 @@ AC_ARG_ENABLE([grub-emu-pci],
[AS_HELP_STRING([--enable-grub-emu-pci],
[build and install the `grub-emu' debugging utility with PCI support (potentially dangerous) (default=no)])])
+# Get the filename or the whole disk and open it.
+# Known to work on NetBSD. Used in util/deviceiter.c.
+AC_CHECK_LIB(util, opendisk, [LIBUTIL="-lutil"
+ AC_DEFINE(HAVE_OPENDISK, 1, [Define if opendisk() in -lutil can be used])])
+AC_SUBST([LIBUTIL])
+
if test "$platform" = emu; then
missing_ncurses=
[# Check for curses libraries.]

View file

@ -1,22 +1,29 @@
--- util/getroot.c.orig 2009-12-29 00:43:31.000000000 +0100
+++ util/getroot.c
@@ -266,8 +266,14 @@ find_root_device (const char *dir, dev_t
--- util/getroot.c.orig 2010-01-02 10:53:01.000000000 +0100
+++ util/getroot.c 2010-01-02 12:10:18.000000000 +0100
@@ -264,10 +264,19 @@ find_root_device (const char *dir, dev_t
/* Found! */
char *res;
char *cwd;
+#if defined(__NetBSD__)
+ /* Convert this block device to its character (raw) device. */
+ const char *template = "%s/r%s";
+ const int extra_len = 3;
+#else
+ /* Keep the device name as it is. */
+ const char *template = "%s/%s";
+ const int extra_len = 2;
+#endif
cwd = xgetcwd ();
+#if defined(__NetBSD__)
+ /* Convert this block device to its character (raw) device */
+ res = xmalloc (strlen (cwd) + strlen (ent->d_name) + 3);
+ sprintf (res, "%s/r%s", cwd, ent->d_name);
+#else
res = xmalloc (strlen (cwd) + strlen (ent->d_name) + 2);
sprintf (res, "%s/%s", cwd, ent->d_name);
+#endif
- res = xmalloc (strlen (cwd) + strlen (ent->d_name) + 2);
- sprintf (res, "%s/%s", cwd, ent->d_name);
+ res = xmalloc (strlen (cwd) + strlen (ent->d_name) + extra_len);
+ sprintf (res, template, cwd, ent->d_name);
strip_extra_slashes (res);
free (cwd);
--- util/grub-probe.c.orig 2009-12-29 00:43:31.000000000 +0100
+++ util/grub-probe.c
--- util/grub-probe.c.orig 2010-01-02 10:53:01.000000000 +0100
+++ util/grub-probe.c 2010-01-02 11:55:24.000000000 +0100
@@ -111,7 +111,7 @@ probe (const char *path, char *device_na
if (path == NULL)
@ -26,16 +33,18 @@
if (! grub_util_check_char_device (device_name))
grub_util_error ("%s is not a character device.\n", device_name);
#else
--- util/hostdisk.c.orig 2009-12-29 00:43:31.000000000 +0100
+++ util/hostdisk.c
@@ -97,6 +97,15 @@ struct hd_geometry
--- util/hostdisk.c.orig 2010-01-02 10:53:01.000000000 +0100
+++ util/hostdisk.c 2010-01-02 12:04:58.000000000 +0100
@@ -97,6 +97,17 @@ struct hd_geometry
# include <sys/disk.h>
#endif
+#if defined(__NetBSD__)
+# include <sys/ioctl.h>
+# include <sys/disklabel.h> /* struct disklabel */
+# include <util.h> /* getrawpartition */
+# ifdef HAVE_GETRAWPARTITION
+# include <util.h> /* getrawpartition */
+# endif /* HAVE_GETRAWPARTITION */
+# ifndef RAW_FLOPPY_MAJOR
+# define RAW_FLOPPY_MAJOR 9
+# endif /* ! RAW_FLOPPY_MAJOR */
@ -44,7 +53,7 @@
struct
{
char *drive;
@@ -191,16 +200,20 @@ grub_util_biosdisk_open (const char *nam
@@ -191,16 +202,20 @@ grub_util_biosdisk_open (const char *nam
return GRUB_ERR_NONE;
}
#elif defined(__linux__) || defined(__CYGWIN__) || defined(__FreeBSD__) || \
@ -67,7 +76,7 @@
if (fstat (fd, &st) < 0 || ! S_ISCHR (st.st_mode))
# else
if (fstat (fd, &st) < 0 || ! S_ISBLK (st.st_mode))
@@ -214,6 +227,11 @@ grub_util_biosdisk_open (const char *nam
@@ -214,6 +229,11 @@ grub_util_biosdisk_open (const char *nam
if (ioctl (fd, DIOCGMEDIASIZE, &nr))
# elif defined(__APPLE__)
if (ioctl (fd, DKIOCGETBLOCKCOUNT, &nr))
@ -79,7 +88,7 @@
# else
if (ioctl (fd, BLKGETSIZE64, &nr))
# endif
@@ -224,14 +242,16 @@ grub_util_biosdisk_open (const char *nam
@@ -224,14 +244,16 @@ grub_util_biosdisk_open (const char *nam
close (fd);
@ -99,7 +108,7 @@
grub_util_info ("the size of %s is %llu", name, disk->total_sectors);
@@ -683,7 +703,7 @@ make_device_name (int drive, int dos_par
@@ -683,7 +705,7 @@ make_device_name (int drive, int dos_par
dos_part_str = xasprintf (",%d", dos_part + 1);
if (bsd_part >= 0)
@ -108,7 +117,7 @@
ret = xasprintf ("%s%s%s", map[drive].drive,
dos_part_str ? : "",
@@ -853,6 +873,26 @@ convert_system_partition_to_system_disk
@@ -853,6 +875,28 @@ convert_system_partition_to_system_disk
}
return path;
@ -124,8 +133,10 @@
+ if (grub_isalpha(*q) && grub_isdigit(*(q-1)))
+ {
+ int rawpart;
+# ifdef HAVE_GETRAWPARTITION
+ rawpart = getrawpartition();
+ if (rawpart < 0)
+# endif /* HAVE_GETRAWPARTITION */
+ rawpart = 3; /* default on i386 */
+ *q = 'a' + rawpart;
+ }
@ -135,7 +146,7 @@
#else
# warning "The function `convert_system_partition_to_system_disk' might not work on your OS correctly."
return xstrdup (os_dev);
@@ -923,7 +963,7 @@ grub_util_biosdisk_get_grub_dev (const c
@@ -923,7 +967,7 @@ grub_util_biosdisk_get_grub_dev (const c
== 0)
return make_device_name (drive, -1, -1);
@ -144,7 +155,7 @@
if (! S_ISCHR (st.st_mode))
#else
if (! S_ISBLK (st.st_mode))
@@ -1107,6 +1147,133 @@ grub_util_biosdisk_get_grub_dev (const c
@@ -1107,6 +1151,133 @@ grub_util_biosdisk_get_grub_dev (const c
return make_device_name (drive, dos_part, bsd_part);
}
@ -278,3 +289,26 @@
#else
# warning "The function `grub_util_biosdisk_get_grub_dev' might not work on your OS correctly."
return make_device_name (drive, -1, -1);
--- configure.ac.orig 2010-01-02 10:52:51.000000000 +0100
+++ configure.ac 2010-01-02 11:52:55.000000000 +0100
@@ -208,6 +208,20 @@ AC_CHECK_FUNCS(memmove sbrk strdup lstat
AC_CHECK_HEADERS(sys/mkdev.h sys/sysmacros.h malloc.h termios.h sys/types.h)
AC_CHECK_HEADERS(unistd.h string.h strings.h sys/stat.h sys/fcntl.h)
+# For opendisk() and getrawpartition() on NetBSD.
+# Used in util/deviceiter.c and in util/hostdisk.c.
+AC_CHECK_HEADER([util.h], [
+ AC_CHECK_LIB([util], [opendisk], [
+ LIBUTIL="-lutil"
+ AC_DEFINE(HAVE_OPENDISK, 1, [Define if opendisk() in -lutil can be used])
+ ])
+ AC_CHECK_LIB([util], [getrawpartition], [
+ LIBUTIL="-lutil"
+ AC_DEFINE(HAVE_GETRAWPARTITION, 1, [Define if getrawpartition() in -lutil can be used])
+ ])
+])
+AC_SUBST([LIBUTIL])
+
#
# Check for target programs.
#