|
|
f96e0b |
From 25ec194a39ae32af2000600ee2e6e1d28230fa98 Mon Sep 17 00:00:00 2001
|
|
|
f96e0b |
From: Vladimir 'phcoder' Serbinenko <phcoder@gmail.com>
|
|
|
f96e0b |
Date: Mon, 29 Apr 2013 12:14:57 +0200
|
|
|
f96e0b |
Subject: [PATCH 388/482] * grub-core/commands/nativedisk.c: Customize
|
|
|
f96e0b |
the list of modules on platform. Don't try to search for disks
|
|
|
f96e0b |
already using native drivers.
|
|
|
f96e0b |
|
|
|
f96e0b |
---
|
|
|
f96e0b |
ChangeLog | 5 ++
|
|
|
f96e0b |
grub-core/Makefile.core.def | 4 ++
|
|
|
f96e0b |
grub-core/commands/nativedisk.c | 101 +++++++++++++++++++++++++++++++---------
|
|
|
f96e0b |
3 files changed, 89 insertions(+), 21 deletions(-)
|
|
|
f96e0b |
|
|
|
f96e0b |
diff --git a/ChangeLog b/ChangeLog
|
|
|
f96e0b |
index 99a049a..1ba588d 100644
|
|
|
f96e0b |
--- a/ChangeLog
|
|
|
f96e0b |
+++ b/ChangeLog
|
|
|
f96e0b |
@@ -1,5 +1,10 @@
|
|
|
f96e0b |
2013-04-29 Vladimir Serbinenko <phcoder@gmail.com>
|
|
|
f96e0b |
|
|
|
f96e0b |
+ * grub-core/commands/nativedisk.c: Customize the list of modules on
|
|
|
f96e0b |
+ platform. Don't try to search for disks already using native drivers.
|
|
|
f96e0b |
+
|
|
|
f96e0b |
+2013-04-29 Vladimir Serbinenko <phcoder@gmail.com>
|
|
|
f96e0b |
+
|
|
|
f96e0b |
* grub-core/bus/usb/uhci.c: Fix DMA handling and enable on all PCI
|
|
|
f96e0b |
platforms.
|
|
|
f96e0b |
|
|
|
f96e0b |
diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def
|
|
|
f96e0b |
index dcb92ef..ebcd01d 100644
|
|
|
f96e0b |
--- a/grub-core/Makefile.core.def
|
|
|
f96e0b |
+++ b/grub-core/Makefile.core.def
|
|
|
f96e0b |
@@ -510,6 +510,10 @@ module = {
|
|
|
f96e0b |
module = {
|
|
|
f96e0b |
name = nativedisk;
|
|
|
f96e0b |
common = commands/nativedisk.c;
|
|
|
f96e0b |
+
|
|
|
f96e0b |
+ enable = x86;
|
|
|
f96e0b |
+ enable = mips_loongson;
|
|
|
f96e0b |
+ enable = mips_qemu_mips;
|
|
|
f96e0b |
};
|
|
|
f96e0b |
|
|
|
f96e0b |
module = {
|
|
|
f96e0b |
diff --git a/grub-core/commands/nativedisk.c b/grub-core/commands/nativedisk.c
|
|
|
f96e0b |
index 333fc82..453faad 100644
|
|
|
f96e0b |
--- a/grub-core/commands/nativedisk.c
|
|
|
f96e0b |
+++ b/grub-core/commands/nativedisk.c
|
|
|
f96e0b |
@@ -31,17 +31,67 @@
|
|
|
f96e0b |
|
|
|
f96e0b |
GRUB_MOD_LICENSE ("GPLv3+");
|
|
|
f96e0b |
|
|
|
f96e0b |
-static const char *modnames_def[] = { "pata", "ahci", "usbms", "ohci", "uhci", "ehci" };
|
|
|
f96e0b |
+static const char *modnames_def[] = {
|
|
|
f96e0b |
+ /* FIXME: autogenerate this. */
|
|
|
f96e0b |
+#if defined (__i386__) || defined (__x86_64__) || defined (GRUB_MACHINE_MIPS_LOONGSON)
|
|
|
f96e0b |
+ "pata", "ahci", "usbms", "ohci", "uhci", "ehci"
|
|
|
f96e0b |
+#elif defined (GRUB_MACHINE_MIPS_QEMU_MIPS)
|
|
|
f96e0b |
+ "pata"
|
|
|
f96e0b |
+#else
|
|
|
f96e0b |
+#error "Fill this"
|
|
|
f96e0b |
+#endif
|
|
|
f96e0b |
+ };
|
|
|
f96e0b |
|
|
|
f96e0b |
static grub_err_t
|
|
|
f96e0b |
-get_uuid (const char *name, char **uuid)
|
|
|
f96e0b |
+get_uuid (const char *name, char **uuid, int getnative)
|
|
|
f96e0b |
{
|
|
|
f96e0b |
grub_device_t dev;
|
|
|
f96e0b |
grub_fs_t fs = 0;
|
|
|
f96e0b |
|
|
|
f96e0b |
+ *uuid = 0;
|
|
|
f96e0b |
+
|
|
|
f96e0b |
dev = grub_device_open (name);
|
|
|
f96e0b |
if (!dev)
|
|
|
f96e0b |
return grub_errno;
|
|
|
f96e0b |
+
|
|
|
f96e0b |
+ if (!dev->disk)
|
|
|
f96e0b |
+ {
|
|
|
f96e0b |
+ grub_dprintf ("nativedisk", "Skipping non-disk\n");
|
|
|
f96e0b |
+ return 0;
|
|
|
f96e0b |
+ }
|
|
|
f96e0b |
+
|
|
|
f96e0b |
+ switch (dev->disk->dev->id)
|
|
|
f96e0b |
+ {
|
|
|
f96e0b |
+ /* Firmware disks. */
|
|
|
f96e0b |
+ case GRUB_DISK_DEVICE_BIOSDISK_ID:
|
|
|
f96e0b |
+ case GRUB_DISK_DEVICE_OFDISK_ID:
|
|
|
f96e0b |
+ case GRUB_DISK_DEVICE_EFIDISK_ID:
|
|
|
f96e0b |
+ case GRUB_DISK_DEVICE_NAND_ID:
|
|
|
f96e0b |
+ case GRUB_DISK_DEVICE_ARCDISK_ID:
|
|
|
f96e0b |
+ case GRUB_DISK_DEVICE_HOSTDISK_ID:
|
|
|
f96e0b |
+ break;
|
|
|
f96e0b |
+
|
|
|
f96e0b |
+ /* Native disks. */
|
|
|
f96e0b |
+ case GRUB_DISK_DEVICE_ATA_ID:
|
|
|
f96e0b |
+ case GRUB_DISK_DEVICE_SCSI_ID:
|
|
|
f96e0b |
+ if (getnative)
|
|
|
f96e0b |
+ break;
|
|
|
f96e0b |
+
|
|
|
f96e0b |
+ /* Virtual disks. */
|
|
|
f96e0b |
+ case GRUB_DISK_DEVICE_PROCFS_ID:
|
|
|
f96e0b |
+ case GRUB_DISK_DEVICE_HOST_ID:
|
|
|
f96e0b |
+ /* GRUB-only memdisk. Can't match any of firmware devices. */
|
|
|
f96e0b |
+ case GRUB_DISK_DEVICE_MEMDISK_ID:
|
|
|
f96e0b |
+ grub_dprintf ("nativedisk", "Skipping native disk %s\n",
|
|
|
f96e0b |
+ dev->disk->name);
|
|
|
f96e0b |
+ return 0;
|
|
|
f96e0b |
+
|
|
|
f96e0b |
+ /* FIXME: those probably need special handling. */
|
|
|
f96e0b |
+ case GRUB_DISK_DEVICE_LOOPBACK_ID:
|
|
|
f96e0b |
+ case GRUB_DISK_DEVICE_DISKFILTER_ID:
|
|
|
f96e0b |
+ case GRUB_DISK_DEVICE_CRYPTODISK_ID:
|
|
|
f96e0b |
+ break;
|
|
|
f96e0b |
+ }
|
|
|
f96e0b |
if (dev)
|
|
|
f96e0b |
fs = grub_fs_probe (dev);
|
|
|
f96e0b |
if (!fs)
|
|
|
f96e0b |
@@ -49,7 +99,7 @@ get_uuid (const char *name, char **uuid)
|
|
|
f96e0b |
grub_device_close (dev);
|
|
|
f96e0b |
return grub_errno;
|
|
|
f96e0b |
}
|
|
|
f96e0b |
- if (!fs->uuid || fs->uuid (dev, uuid))
|
|
|
f96e0b |
+ if (!fs->uuid || fs->uuid (dev, uuid) || !*uuid)
|
|
|
f96e0b |
{
|
|
|
f96e0b |
grub_device_close (dev);
|
|
|
f96e0b |
|
|
|
f96e0b |
@@ -77,14 +127,17 @@ iterate_device (const char *name, void *data)
|
|
|
f96e0b |
struct search_ctx *ctx = data;
|
|
|
f96e0b |
char *cur_uuid;
|
|
|
f96e0b |
|
|
|
f96e0b |
- if (get_uuid (name, &cur_uuid))
|
|
|
f96e0b |
+ if (get_uuid (name, &cur_uuid, 1))
|
|
|
f96e0b |
{
|
|
|
f96e0b |
if (grub_errno == GRUB_ERR_UNKNOWN_FS)
|
|
|
f96e0b |
grub_errno = 0;
|
|
|
f96e0b |
grub_print_error ();
|
|
|
f96e0b |
return 0;
|
|
|
f96e0b |
}
|
|
|
f96e0b |
- if (grub_strcasecmp (cur_uuid, ctx->prefix_uuid) == 0)
|
|
|
f96e0b |
+
|
|
|
f96e0b |
+ grub_dprintf ("nativedisk", "checking %s: %s\n", name,
|
|
|
f96e0b |
+ cur_uuid);
|
|
|
f96e0b |
+ if (ctx->prefix_uuid && grub_strcasecmp (cur_uuid, ctx->prefix_uuid) == 0)
|
|
|
f96e0b |
{
|
|
|
f96e0b |
char *prefix;
|
|
|
f96e0b |
prefix = grub_xasprintf ("(%s)/%s", name, ctx->prefix_path);
|
|
|
f96e0b |
@@ -92,7 +145,7 @@ iterate_device (const char *name, void *data)
|
|
|
f96e0b |
grub_free (prefix);
|
|
|
f96e0b |
ctx->prefix_found = 1;
|
|
|
f96e0b |
}
|
|
|
f96e0b |
- if (grub_strcasecmp (cur_uuid, ctx->root_uuid) == 0)
|
|
|
f96e0b |
+ if (ctx->root_uuid && grub_strcasecmp (cur_uuid, ctx->root_uuid) == 0)
|
|
|
f96e0b |
{
|
|
|
f96e0b |
grub_env_set ("root", name);
|
|
|
f96e0b |
ctx->root_found = 1;
|
|
|
f96e0b |
@@ -109,9 +162,7 @@ grub_cmd_nativedisk (grub_command_t cmd __attribute__ ((unused)),
|
|
|
f96e0b |
const char *path_prefix = 0;
|
|
|
f96e0b |
int mods_loaded = 0;
|
|
|
f96e0b |
grub_dl_t *mods;
|
|
|
f96e0b |
- struct search_ctx ctx;
|
|
|
f96e0b |
const char **args;
|
|
|
f96e0b |
- grub_fs_autoload_hook_t saved_autoload;
|
|
|
f96e0b |
int i;
|
|
|
f96e0b |
|
|
|
f96e0b |
if (argc == 0)
|
|
|
f96e0b |
@@ -138,7 +189,7 @@ grub_cmd_nativedisk (grub_command_t cmd __attribute__ ((unused)),
|
|
|
f96e0b |
if (!mods)
|
|
|
f96e0b |
return grub_errno;
|
|
|
f96e0b |
|
|
|
f96e0b |
- if (get_uuid (NULL, &uuid_root))
|
|
|
f96e0b |
+ if (get_uuid (NULL, &uuid_root, 0))
|
|
|
f96e0b |
return grub_errno;
|
|
|
f96e0b |
|
|
|
f96e0b |
prefdev = grub_file_get_device_name (prefix);
|
|
|
f96e0b |
@@ -148,12 +199,15 @@ grub_cmd_nativedisk (grub_command_t cmd __attribute__ ((unused)),
|
|
|
f96e0b |
prefdev = 0;
|
|
|
f96e0b |
}
|
|
|
f96e0b |
|
|
|
f96e0b |
- if (get_uuid (prefdev, &uuid_prefix))
|
|
|
f96e0b |
+ if (get_uuid (prefdev, &uuid_prefix, 0))
|
|
|
f96e0b |
{
|
|
|
f96e0b |
grub_free (uuid_root);
|
|
|
f96e0b |
return grub_errno;
|
|
|
f96e0b |
}
|
|
|
f96e0b |
|
|
|
f96e0b |
+ grub_dprintf ("nativedisk", "uuid_prefix = %s, uuid_root = %s\n",
|
|
|
f96e0b |
+ uuid_prefix, uuid_root);
|
|
|
f96e0b |
+
|
|
|
f96e0b |
for (mods_loaded = 0; mods_loaded < argc; mods_loaded++)
|
|
|
f96e0b |
{
|
|
|
f96e0b |
char *filename;
|
|
|
f96e0b |
@@ -205,21 +259,26 @@ grub_cmd_nativedisk (grub_command_t cmd __attribute__ ((unused)),
|
|
|
f96e0b |
if (mods[i])
|
|
|
f96e0b |
grub_dl_init (mods[i]);
|
|
|
f96e0b |
|
|
|
f96e0b |
- /* No need to autoload FS since obviously we already have the necessary fs modules. */
|
|
|
f96e0b |
- saved_autoload = grub_fs_autoload_hook;
|
|
|
f96e0b |
- grub_fs_autoload_hook = 0;
|
|
|
f96e0b |
+ if (uuid_prefix || uuid_root)
|
|
|
f96e0b |
+ {
|
|
|
f96e0b |
+ struct search_ctx ctx;
|
|
|
f96e0b |
+ grub_fs_autoload_hook_t saved_autoload;
|
|
|
f96e0b |
|
|
|
f96e0b |
- ctx.root_uuid = uuid_root;
|
|
|
f96e0b |
- ctx.prefix_uuid = uuid_prefix;
|
|
|
f96e0b |
- ctx.prefix_path = path_prefix;
|
|
|
f96e0b |
- ctx.prefix_found = 0;
|
|
|
f96e0b |
- ctx.root_found = 0;
|
|
|
f96e0b |
+ /* No need to autoload FS since obviously we already have the necessary fs modules. */
|
|
|
f96e0b |
+ saved_autoload = grub_fs_autoload_hook;
|
|
|
f96e0b |
+ grub_fs_autoload_hook = 0;
|
|
|
f96e0b |
|
|
|
f96e0b |
- /* FIXME: try to guess the correct values. */
|
|
|
f96e0b |
- grub_device_iterate (iterate_device, &ctx;;
|
|
|
f96e0b |
+ ctx.root_uuid = uuid_root;
|
|
|
f96e0b |
+ ctx.prefix_uuid = uuid_prefix;
|
|
|
f96e0b |
+ ctx.prefix_path = path_prefix;
|
|
|
f96e0b |
+ ctx.prefix_found = !uuid_prefix;
|
|
|
f96e0b |
+ ctx.root_found = !uuid_root;
|
|
|
f96e0b |
|
|
|
f96e0b |
- grub_fs_autoload_hook = saved_autoload;
|
|
|
f96e0b |
+ /* FIXME: try to guess the correct values. */
|
|
|
f96e0b |
+ grub_device_iterate (iterate_device, &ctx;;
|
|
|
f96e0b |
|
|
|
f96e0b |
+ grub_fs_autoload_hook = saved_autoload;
|
|
|
f96e0b |
+ }
|
|
|
f96e0b |
grub_free (uuid_root);
|
|
|
f96e0b |
grub_free (uuid_prefix);
|
|
|
f96e0b |
|
|
|
f96e0b |
--
|
|
|
f96e0b |
1.8.2.1
|
|
|
f96e0b |
|