[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Current Grub2 & problem with /boot on different drive
From: |
Vladimir 'phcoder' Serbinenko |
Subject: |
Re: Current Grub2 & problem with /boot on different drive |
Date: |
Tue, 22 Sep 2009 09:56:07 +0200 |
User-agent: |
Mozilla-Thunderbird 2.0.0.22 (X11/20090701) |
Try attached WIP patch
Dean Loros wrote:
> Greetings--
>
> Well Vladimir, the modification to grub.cfg makes a 20sec
> difference--times went from 3 min 50 sec to 3 min 30 sec--better, but
> still a "bit" long :) So I would say that option #3 has very little
> effect & I really do not want to hardcode as per option #2....I am open
> to "interesting" mods to bring the time down to "normal" levels & It
> looks like Colin is willing to do some package building in between his
> busy workweek. So what are your thoughts as how this can be approached?
>
>
> Date: Mon, 21 Sep 2009 15:58:17 +0100 From: Colin Watson
> <address@hidden> Subject: Re: Current Grub2 & problem with /boot on
> different drive To: The development of GRUB 2 <address@hidden>
> Message-ID: <address@hidden> Content-Type:
> text/plain; charset=us-ascii On Mon, Sep 21, 2009 at 04:22:53PM +0200,
> Vladimir 'phcoder' Serbinenko wrote:
>
>
>>> Colin Watson wrote:
>>>
>>
>>
>>>>> On Sun, Sep 20, 2009 at 10:00:13PM +0200, Vladimir 'phcoder' Serbinenko
>>>>> wrote:
>>>>>
>>>
>>>
>>>>>>> As a workaround for time being you can use one or more of the following:
>>>>>>> 1) Increase cache size. Can this be done in 1.97?
>>>>>>> Change include/grub/disk.h and replace
>>>>>>> #define GRUB_DISK_CACHE_NUM 1021
>>>>>>> with a bigger number
>>>>>>>
>>>>
>>>>
>>>>> I'm a little baffled. Why does the disk cache size make a difference
>>>>> here? He has four disks - I'd have thought that 1021 would be plenty.
>>>>>
>>>
>>>
>>> 1021 is the number of cached 4KiB blocks and is used in hash
>>> calculations. If he has a lot of cache misses it will result in long
>>> boot times
>>>
>>
>>
> Do you have a recommendation for a new value? I can build a test package
> and ask Dean to try it out.
>
>
>
diff --git a/commands/search.c b/commands/search.c
index 0cfd0eb..4a4ca6f 100644
--- a/commands/search.c
+++ b/commands/search.c
@@ -25,29 +25,10 @@
#include <grub/device.h>
#include <grub/file.h>
#include <grub/env.h>
-#include <grub/extcmd.h>
+#include <grub/command.h>
-static const struct grub_arg_option options[] =
- {
- {"file", 'f', 0, "search devices by a file", 0, 0},
- {"label", 'l', 0, "search devices by a filesystem label", 0, 0},
- {"fs-uuid", 'u', 0, "search devices by a filesystem UUID",
0, 0},
- {"set", 's', GRUB_ARG_OPTION_OPTIONAL, "set a variable to the
first device found", "VAR", ARG_TYPE_STRING},
- {"no-floppy", 'n', 0, "do not probe any floppy drive", 0, 0},
- {0, 0, 0, 0, 0, 0}
- };
-
-enum options
- {
- SEARCH_FILE,
- SEARCH_LABEL,
- SEARCH_FS_UUID,
- SEARCH_SET,
- SEARCH_NO_FLOPPY,
- };
-
-static void
-search_fs (const char *key, const char *var, int no_floppy, enum options type)
+void
+FUNC_NAME (const char *key, const char *var, int no_floppy)
{
int count = 0;
char *buf = NULL;
@@ -63,7 +44,7 @@ search_fs (const char *key, const char *var, int no_floppy,
enum options type)
name[0] == 'f' && name[1] == 'd' && name[2] >= '0' && name[2] <= '9')
return 0;
- if (type == SEARCH_FILE)
+#ifdef DO_SEARCH_FILE
{
grub_size_t len;
char *p;
@@ -84,27 +65,29 @@ search_fs (const char *key, const char *var, int no_floppy,
enum options type)
grub_file_close (file);
}
}
- else
+#else
{
- /* type is SEARCH_FS_UUID or SEARCH_LABEL */
+ /* SEARCH_FS_UUID or SEARCH_LABEL */
grub_device_t dev;
grub_fs_t fs;
- int (*compare_fn) (const char *, const char *);
char *quid;
dev = grub_device_open (name);
if (dev)
{
fs = grub_fs_probe (dev);
- compare_fn =
- (type == SEARCH_FS_UUID) ? grub_strcasecmp : grub_strcmp;
- if (fs && ((type == SEARCH_FS_UUID) ? fs->uuid : fs->label))
+#ifdef DO_SEARCH_FS_UUID
+#define compare_fn grub_strcasecmp
+#define read_fn uuid
+#else
+#define compare_fn grub_strcmp
+#define read_fn label
+#endif
+
+ if (fs && fs->read_fn)
{
- if (type == SEARCH_FS_UUID)
- fs->uuid (dev, &quid);
- else
- fs->label (dev, &quid);
+ fs->read_fn (dev, &quid);
if (grub_errno == GRUB_ERR_NONE && quid)
{
@@ -118,6 +101,7 @@ search_fs (const char *key, const char *var, int no_floppy,
enum options type)
grub_device_close (dev);
}
}
+#endif
if (found)
{
@@ -156,45 +140,42 @@ search_fs (const char *key, const char *var, int
no_floppy, enum options type)
}
static grub_err_t
-grub_cmd_search (grub_extcmd_t cmd, int argc, char **args)
+grub_cmd_do_search (grub_command_t cmd __attribute__ ((unused)), int argc,
+ char **args)
{
- struct grub_arg_list *state = cmd->state;
- const char *var = 0;
-
if (argc == 0)
- return grub_error (GRUB_ERR_INVALID_COMMAND, "no argument specified");
-
- if (state[SEARCH_SET].set)
- var = state[SEARCH_SET].arg ? state[SEARCH_SET].arg : "root";
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, "no argument specified");
- if (state[SEARCH_LABEL].set)
- search_fs (args[0], var, state[SEARCH_NO_FLOPPY].set, SEARCH_LABEL);
- else if (state[SEARCH_FS_UUID].set)
- search_fs (args[0], var, state[SEARCH_NO_FLOPPY].set, SEARCH_FS_UUID);
- else if (state[SEARCH_FILE].set)
- search_fs (args[0], var, state[SEARCH_NO_FLOPPY].set, SEARCH_FILE);
- else
- return grub_error (GRUB_ERR_INVALID_COMMAND, "unspecified search type");
+ FUNC_NAME (args[0], argc == 1 ? 0 : args[1], 0);
return grub_errno;
}
-static grub_extcmd_t cmd;
+static grub_command_t cmd;
-GRUB_MOD_INIT(search)
+#if defined (DO_SEARCH_FILE)
+GRUB_MOD_INIT(search_file)
+#elif defined (DO_SEARCH_FS_UUID)
+GRUB_MOD_INIT(search_fs_uuid)
+#else
+GRUB_MOD_INIT(search_fs_label)
+#endif
{
cmd =
- grub_register_extcmd ("search", grub_cmd_search,
- GRUB_COMMAND_FLAG_BOTH,
- "search [-f|-l|-u|-s|-n] NAME",
- "Search devices by file, filesystem label or
filesystem UUID."
- " If --set is specified, the first device found is"
- " set to a variable. If no variable name is"
- " specified, \"root\" is used.",
- options);
+ grub_register_command (COMMAND_NAME, grub_cmd_do_search,
+ COMMAND_NAME " NAME [VARIABLE]",
+ "Search devices by " SEARCH_TARGET "."
+ " If VARIABLE is specified, the first device found is"
+ " set to a variable.");
}
-GRUB_MOD_FINI(search)
+#if defined (DO_SEARCH_FILE)
+GRUB_MOD_FINI(search_file)
+#elif defined (DO_SEARCH_FS_UUID)
+GRUB_MOD_FINI(search_fs_uuid)
+#else
+GRUB_MOD_FINI(search_fs_label)
+#endif
{
- grub_unregister_extcmd (cmd);
+ grub_unregister_command (cmd);
}
diff --git a/commands/search_file.c b/commands/search_file.c
new file mode 100644
index 0000000..b13d235
--- /dev/null
+++ b/commands/search_file.c
@@ -0,0 +1,5 @@
+#define DO_SEARCH_FILE 1
+#define FUNC_NAME grub_search_file
+#define COMMAND_NAME "search.file"
+#define SEARCH_TARGET "file"
+#include "search.c"
diff --git a/commands/search_label.c b/commands/search_label.c
new file mode 100644
index 0000000..12710f9
--- /dev/null
+++ b/commands/search_label.c
@@ -0,0 +1,5 @@
+#define DO_SEARCH_FS_LABEL 1
+#define FUNC_NAME grub_search_fs_label
+#define COMMAND_NAME "search.fs_label"
+#define SEARCH_TARGET "filesystem label"
+#include "search.c"
diff --git a/commands/search_uuid.c b/commands/search_uuid.c
new file mode 100644
index 0000000..9767d65
--- /dev/null
+++ b/commands/search_uuid.c
@@ -0,0 +1,5 @@
+#define DO_SEARCH_FS_UUID 1
+#define FUNC_NAME grub_search_fs_uuid
+#define COMMAND_NAME "search.fs_uuid"
+#define SEARCH_TARGET "filesystem UUID"
+#include "search.c"
diff --git a/commands/search_wrap.c b/commands/search_wrap.c
new file mode 100644
index 0000000..bc13e16
--- /dev/null
+++ b/commands/search_wrap.c
@@ -0,0 +1,91 @@
+/* search.c - search devices based on a file or a filesystem label */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2005,2007,2008,2009 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/>.
+ */
+
+#include <grub/dl.h>
+#include <grub/extcmd.h>
+
+void
+grub_search_fs_uuid (const char *key, const char *var, int no_floppy);
+void
+grub_search_fs_label (const char *key, const char *var, int no_floppy);
+void
+grub_search_file (const char *key, const char *var, int no_floppy);
+
+static const struct grub_arg_option options[] =
+ {
+ {"file", 'f', 0, "search devices by a file", 0, 0},
+ {"label", 'l', 0, "search devices by a filesystem label", 0, 0},
+ {"fs-uuid", 'u', 0, "search devices by a filesystem UUID",
0, 0},
+ {"set", 's', GRUB_ARG_OPTION_OPTIONAL, "set a variable to the
first device found", "VAR", ARG_TYPE_STRING},
+ {"no-floppy", 'n', 0, "do not probe any floppy drive", 0, 0},
+ {0, 0, 0, 0, 0, 0}
+ };
+
+enum options
+ {
+ SEARCH_FILE,
+ SEARCH_LABEL,
+ SEARCH_FS_UUID,
+ SEARCH_SET,
+ SEARCH_NO_FLOPPY,
+ };
+
+static grub_err_t
+grub_cmd_search (grub_extcmd_t cmd, int argc, char **args)
+{
+ struct grub_arg_list *state = cmd->state;
+ const char *var = 0;
+
+ if (argc == 0)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, "no argument specified");
+
+ if (state[SEARCH_SET].set)
+ var = state[SEARCH_SET].arg ? state[SEARCH_SET].arg : "root";
+
+ if (state[SEARCH_LABEL].set)
+ grub_search_fs_label (args[0], var, state[SEARCH_NO_FLOPPY].set);
+ else if (state[SEARCH_FS_UUID].set)
+ grub_search_fs_uuid (args[0], var, state[SEARCH_NO_FLOPPY].set);
+ else if (state[SEARCH_FILE].set)
+ grub_search_file (args[0], var, state[SEARCH_NO_FLOPPY].set);
+ else
+ return grub_error (GRUB_ERR_INVALID_COMMAND, "unspecified search type");
+
+ return grub_errno;
+}
+
+static grub_extcmd_t cmd;
+
+GRUB_MOD_INIT(search)
+{
+ cmd =
+ grub_register_extcmd ("search", grub_cmd_search,
+ GRUB_COMMAND_FLAG_BOTH,
+ "search [-f|-l|-u|-s|-n] NAME",
+ "Search devices by file, filesystem label or
filesystem UUID."
+ " If --set is specified, the first device found is"
+ " set to a variable. If no variable name is"
+ " specified, \"root\" is used.",
+ options);
+}
+
+GRUB_MOD_FINI(search)
+{
+ grub_unregister_extcmd (cmd);
+}
diff --git a/conf/common.rmk b/conf/common.rmk
index e18dd10..d18a2f5 100644
--- a/conf/common.rmk
+++ b/conf/common.rmk
@@ -363,8 +363,9 @@ scsi_mod_LDFLAGS = $(COMMON_LDFLAGS)
# Commands.
pkglib_MODULES += minicmd.mod extcmd.mod hello.mod handler.mod \
- ls.mod cmp.mod cat.mod help.mod search.mod loopback.mod \
- fs_file.mod fs_uuid.mod configfile.mod echo.mod \
+ ls.mod cmp.mod cat.mod help.mod search_file.mod \
+ search_fs_uuid.mod search_fs_label.mod search.mod loopback.mod \
+ configfile.mod echo.mod \
terminfo.mod test.mod blocklist.mod hexdump.mod \
read.mod sleep.mod loadenv.mod crc.mod parttool.mod \
msdospart.mod memrw.mod normal.mod sh.mod lua.mod \
@@ -437,10 +438,25 @@ help_mod_CFLAGS = $(COMMON_CFLAGS)
help_mod_LDFLAGS = $(COMMON_LDFLAGS)
# For search.mod.
-search_mod_SOURCES = commands/search.c
+search_mod_SOURCES = commands/search_wrap.c
search_mod_CFLAGS = $(COMMON_CFLAGS)
search_mod_LDFLAGS = $(COMMON_LDFLAGS)
+# For search.mod.
+search_file_mod_SOURCES = commands/search_file.c
+search_file_mod_CFLAGS = $(COMMON_CFLAGS)
+search_file_mod_LDFLAGS = $(COMMON_LDFLAGS)
+
+# For search.mod.
+search_fs_label_mod_SOURCES = commands/search_label.c
+search_fs_label_mod_CFLAGS = $(COMMON_CFLAGS)
+search_fs_label_mod_LDFLAGS = $(COMMON_LDFLAGS)
+
+# For search.mod.
+search_fs_uuid_mod_SOURCES = commands/search_uuid.c
+search_fs_uuid_mod_CFLAGS = $(COMMON_CFLAGS)
+search_fs_uuid_mod_LDFLAGS = $(COMMON_LDFLAGS)
+
# For test.mod.
test_mod_SOURCES = commands/test.c
test_mod_CFLAGS = $(COMMON_CFLAGS)
@@ -451,16 +467,6 @@ loopback_mod_SOURCES = disk/loopback.c
loopback_mod_CFLAGS = $(COMMON_CFLAGS)
loopback_mod_LDFLAGS = $(COMMON_LDFLAGS)
-# For fs_file.mod
-fs_file_mod_SOURCES = disk/fs_file.c
-fs_file_mod_CFLAGS = $(COMMON_CFLAGS)
-fs_file_mod_LDFLAGS = $(COMMON_LDFLAGS)
-
-# For fs_uuid.mod
-fs_uuid_mod_SOURCES = disk/fs_uuid.c
-fs_uuid_mod_CFLAGS = $(COMMON_CFLAGS)
-fs_uuid_mod_LDFLAGS = $(COMMON_LDFLAGS)
-
# For configfile.mod
configfile_mod_SOURCES = commands/configfile.c
configfile_mod_CFLAGS = $(COMMON_CFLAGS)
diff --git a/conf/i386-coreboot.rmk b/conf/i386-coreboot.rmk
index 09ec778..79c36ee 100644
--- a/conf/i386-coreboot.rmk
+++ b/conf/i386-coreboot.rmk
@@ -108,7 +108,7 @@ util/grub-emu.c_DEPENDENCIES = grub_emu_init.h
grub_emu_SOURCES = commands/minicmd.c commands/cat.c commands/cmp.c \
commands/configfile.c commands/echo.c commands/help.c \
commands/handler.c commands/ls.c commands/test.c \
- commands/search.c commands/blocklist.c commands/hexdump.c \
+ commands/search_file.c commands/search_label.c commands/search_uuid.c
commands/search_wrap.c commands/blocklist.c commands/hexdump.c \
commands/gptsync.c commands/probe.c commands/xnu_uuid.c \
commands/password.c commands/keystatus.c \
lib/hexdump.c commands/i386/cpuid.c \
diff --git a/conf/i386-efi.rmk b/conf/i386-efi.rmk
index 99ab06f..c9a412a 100644
--- a/conf/i386-efi.rmk
+++ b/conf/i386-efi.rmk
@@ -36,7 +36,7 @@ util/grub-emu.c_DEPENDENCIES = grub_emu_init.h
grub_emu_SOURCES = commands/minicmd.c commands/cat.c commands/cmp.c \
commands/configfile.c commands/help.c \
commands/handler.c commands/ls.c commands/test.c \
- commands/search.c commands/hexdump.c lib/hexdump.c \
+ commands/search_file.c commands/search_label.c commands/search_uuid.c
commands/search_wrap.c commands/hexdump.c lib/hexdump.c \
commands/halt.c commands/reboot.c commands/keystatus.c \
commands/i386/cpuid.c \
commands/password.c \
diff --git a/conf/i386-ieee1275.rmk b/conf/i386-ieee1275.rmk
index 4b640de..6b15b14 100644
--- a/conf/i386-ieee1275.rmk
+++ b/conf/i386-ieee1275.rmk
@@ -62,7 +62,7 @@ util/grub-emu.c_DEPENDENCIES = grub_emu_init.h
grub_emu_SOURCES = commands/minicmd.c commands/cat.c commands/cmp.c \
commands/configfile.c commands/echo.c commands/help.c \
commands/handler.c commands/ls.c commands/test.c \
- commands/search.c commands/blocklist.c commands/hexdump.c \
+ commands/search_file.c commands/search_label.c commands/search_uuid.c
commands/search_wrap.c commands/blocklist.c commands/hexdump.c \
lib/hexdump.c commands/halt.c commands/reboot.c \
lib/envblk.c commands/loadenv.c \
commands/gptsync.c commands/probe.c commands/xnu_uuid.c \
diff --git a/conf/i386-pc.rmk b/conf/i386-pc.rmk
index bf8fbfb..8736422 100644
--- a/conf/i386-pc.rmk
+++ b/conf/i386-pc.rmk
@@ -120,7 +120,7 @@ util/grub-emu.c_DEPENDENCIES = grub_emu_init.h
grub_emu_SOURCES = commands/minicmd.c commands/cat.c commands/cmp.c \
commands/configfile.c commands/echo.c commands/help.c \
commands/handler.c commands/ls.c commands/test.c \
- commands/search.c commands/blocklist.c commands/hexdump.c \
+ commands/search_file.c commands/search_label.c commands/search_uuid.c
commands/search_wrap.c commands/blocklist.c commands/hexdump.c \
lib/hexdump.c commands/i386/pc/halt.c commands/reboot.c \
lib/envblk.c commands/loadenv.c \
commands/gptsync.c commands/probe.c commands/xnu_uuid.c \
diff --git a/conf/powerpc-ieee1275.rmk b/conf/powerpc-ieee1275.rmk
index ee7f9ec..df594cf 100644
--- a/conf/powerpc-ieee1275.rmk
+++ b/conf/powerpc-ieee1275.rmk
@@ -42,7 +42,7 @@ grub_mkdevicemap_SOURCES = util/grub-mkdevicemap.c
util/deviceiter.c \
util/grub-emu.c_DEPENDENCIES = grub_emu_init.h
grub_emu_SOURCES = commands/minicmd.c commands/cat.c commands/cmp.c \
commands/configfile.c commands/help.c \
- commands/search.c commands/handler.c commands/test.c \
+ commands/search_file.c commands/search_label.c commands/search_uuid.c
commands/search_wrap.c commands/handler.c commands/test.c \
commands/ls.c commands/blocklist.c commands/hexdump.c \
lib/hexdump.c commands/halt.c commands/reboot.c \
lib/envblk.c commands/loadenv.c \
diff --git a/conf/sparc64-ieee1275.rmk b/conf/sparc64-ieee1275.rmk
index 62e951a..936d481 100644
--- a/conf/sparc64-ieee1275.rmk
+++ b/conf/sparc64-ieee1275.rmk
@@ -100,7 +100,7 @@ grub_ofpathname_SOURCES =
util/sparc64/ieee1275/grub-ofpathname.c \
util/grub-emu.c_DEPENDENCIES = grub_emu_init.h
grub_emu_SOURCES = commands/minicmd.c commands/cat.c commands/cmp.c \
commands/configfile.c commands/help.c \
- commands/search.c commands/handler.c commands/test.c \
+ commands/search_file.c commands/search_label.c commands/search_uuid.c
commands/search_wrap.c commands/handler.c commands/test.c \
commands/ls.c commands/blocklist.c commands/hexdump.c \
lib/hexdump.c commands/halt.c commands/reboot.c \
lib/envblk.c commands/loadenv.c \
diff --git a/conf/x86_64-efi.rmk b/conf/x86_64-efi.rmk
index 934cd72..a17cd59 100644
--- a/conf/x86_64-efi.rmk
+++ b/conf/x86_64-efi.rmk
@@ -34,7 +34,7 @@ util/grub-emu.c_DEPENDENCIES = grub_emu_init.h
grub_emu_SOURCES = commands/minicmd.c commands/cat.c commands/cmp.c \
commands/configfile.c commands/help.c \
commands/handler.c commands/ls.c commands/test.c \
- commands/search.c commands/hexdump.c lib/hexdump.c \
+ commands/search_file.c commands/search_label.c commands/search_uuid.c
commands/search_wrap.c commands/hexdump.c lib/hexdump.c \
commands/halt.c commands/reboot.c \
commands/i386/cpuid.c \
commands/password.c commands/keystatus.c \
diff --git a/disk/fs_file.c b/disk/fs_file.c
deleted file mode 100644
index e095682..0000000
--- a/disk/fs_file.c
+++ /dev/null
@@ -1,136 +0,0 @@
-/* fs_file.c - Access partition by a file it contains. */
-/*
- * GRUB -- GRand Unified Bootloader
- * Copyright (C) 2009 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/>.
- */
-
-#include <grub/disk.h>
-#include <grub/dl.h>
-#include <grub/file.h>
-#include <grub/misc.h>
-#include <grub/mm.h>
-#include <grub/partition.h>
-
-static grub_device_t
-search_fs_file (const char *key, unsigned long *count)
-{
- char *filename = NULL;
- grub_device_t ret = NULL;
- *count = 0;
-
- auto int iterate_device (const char *name);
- int iterate_device (const char *name)
- {
- int len;
- grub_file_t file;
-
- (*count)++;
-
- len = grub_strlen (name) + 2 + grub_strlen (key) + 1;
- filename = grub_realloc (filename, len);
- if (! filename)
- return 1;
-
- grub_sprintf (filename, "(%s)%s", name, key);
- file = grub_file_open (filename);
- if (file)
- {
- grub_file_close (file);
- ret = grub_device_open (name);
- return 1;
- }
-
- grub_errno = GRUB_ERR_NONE;
- return 0;
- }
-
- grub_device_iterate (iterate_device);
- grub_free (filename);
-
- return ret;
-}
-
-static grub_err_t
-grub_fs_file_open (const char *name, grub_disk_t disk)
-{
- grub_device_t dev;
-
- if (grub_strncmp (name, "FILE=", sizeof ("FILE=") - 1))
- return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "not a FILE virtual volume");
-
- dev = search_fs_file (name + sizeof ("FILE=") - 1, &disk->id);
- if (! dev)
- return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "no matching file found");
-
- disk->total_sectors = dev->disk->total_sectors;
- disk->has_partitions = 0;
- if (dev->disk->partition)
- {
- disk->partition = grub_malloc (sizeof (*disk->partition));
- if (disk->partition)
- grub_memcpy (disk->partition, dev->disk->partition,
- sizeof (*disk->partition));
- }
- else
- disk->partition = NULL;
-
- disk->data = dev;
-
- return GRUB_ERR_NONE;
-}
-
-static void
-grub_fs_file_close (grub_disk_t disk)
-{
- grub_device_t parent = disk->data;
- grub_device_close (parent);
-}
-
-static grub_err_t
-grub_fs_file_read (grub_disk_t disk, grub_disk_addr_t sector,
- grub_size_t size, char *buf)
-{
- grub_device_t parent = disk->data;
- return parent->disk->dev->read (parent->disk, sector, size, buf);
-}
-
-static grub_err_t
-grub_fs_file_write (grub_disk_t disk, grub_disk_addr_t sector,
- grub_size_t size, const char *buf)
-{
- grub_device_t parent = disk->data;
- return parent->disk->dev->write (parent->disk, sector, size, buf);
-}
-
-static struct grub_disk_dev grub_fs_file_dev = {
- .name = "fs_file",
- .id = GRUB_DISK_DEVICE_FILE_ID,
- .open = grub_fs_file_open,
- .close = grub_fs_file_close,
- .read = grub_fs_file_read,
- .write = grub_fs_file_write,
- .next = 0
-};
-
-GRUB_MOD_INIT (fs_file)
-{
- grub_disk_dev_register (&grub_fs_file_dev);
-}
-
-GRUB_MOD_FINI (fs_file)
-{
- grub_disk_dev_unregister (&grub_fs_file_dev);
-}
diff --git a/disk/fs_uuid.c b/disk/fs_uuid.c
deleted file mode 100644
index 6901dba..0000000
--- a/disk/fs_uuid.c
+++ /dev/null
@@ -1,149 +0,0 @@
-/* fs_uuid.c - Access disks by their filesystem UUID. */
-/*
- * GRUB -- GRand Unified Bootloader
- * Copyright (C) 2007,2008 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/>.
- */
-
-#include <grub/disk.h>
-#include <grub/dl.h>
-#include <grub/kernel.h>
-#include <grub/misc.h>
-#include <grub/mm.h>
-#include <grub/types.h>
-
-#include <grub/fs.h>
-#include <grub/partition.h>
-
-static grub_device_t
-search_fs_uuid (const char *key, unsigned long *count)
-{
- *count = 0;
- grub_device_t ret = NULL;
-
- auto int iterate_device (const char *name);
- int iterate_device (const char *name)
- {
- grub_device_t dev;
-
- dev = grub_device_open (name);
- if (dev)
- {
- grub_fs_t fs;
-
- fs = grub_fs_probe (dev);
- if (fs && fs->uuid)
- {
- char *uuid;
-
- (fs->uuid) (dev, &uuid);
- if (grub_errno == GRUB_ERR_NONE && uuid)
- {
- (*count)++;
-
- if (grub_strcasecmp (uuid, key) == 0)
- {
- ret = dev;
- grub_free (uuid);
- return 1;
- }
- grub_free (uuid);
- }
- }
-
- grub_device_close (dev);
- }
-
- grub_errno = GRUB_ERR_NONE;
- return 0;
- }
-
- grub_device_iterate (iterate_device);
-
- return ret;
-}
-
-static grub_err_t
-grub_fs_uuid_open (const char *name, grub_disk_t disk)
-{
- grub_device_t dev;
-
- if (grub_strncmp (name, "UUID=", sizeof ("UUID=")-1))
- return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "not a UUID virtual volume");
-
- dev = search_fs_uuid (name + sizeof ("UUID=") - 1, &disk->id);
- if (! dev)
- return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "no matching UUID found");
-
- disk->total_sectors = dev->disk->total_sectors;
- disk->has_partitions = 0;
- if (dev->disk->partition)
- {
- disk->partition = grub_malloc (sizeof (*disk->partition));
- if (disk->partition)
- grub_memcpy (disk->partition, dev->disk->partition,
- sizeof (*disk->partition));
- }
- else
- disk->partition = NULL;
-
- disk->data = dev;
-
- return GRUB_ERR_NONE;
-}
-
-static void
-grub_fs_uuid_close (grub_disk_t disk __attribute((unused)))
-{
- grub_device_t parent = disk->data;
- grub_device_close (parent);
-}
-
-static grub_err_t
-grub_fs_uuid_read (grub_disk_t disk, grub_disk_addr_t sector,
- grub_size_t size, char *buf)
-{
- grub_device_t parent = disk->data;
- return parent->disk->dev->read (parent->disk, sector, size, buf);
-}
-
-static grub_err_t
-grub_fs_uuid_write (grub_disk_t disk, grub_disk_addr_t sector,
- grub_size_t size, const char *buf)
-{
- grub_device_t parent = disk->data;
- return parent->disk->dev->write (parent->disk, sector, size, buf);
-}
-
-static struct grub_disk_dev grub_fs_uuid_dev =
- {
- .name = "fs_uuid",
- .id = GRUB_DISK_DEVICE_UUID_ID,
- .open = grub_fs_uuid_open,
- .close = grub_fs_uuid_close,
- .read = grub_fs_uuid_read,
- .write = grub_fs_uuid_write,
- .next = 0
- };
-
-GRUB_MOD_INIT(fs_uuid)
-{
- grub_disk_dev_register (&grub_fs_uuid_dev);
-}
-
-GRUB_MOD_FINI(fs_uuid)
-{
- grub_disk_dev_unregister (&grub_fs_uuid_dev);
-}
diff --git a/util/i386/pc/grub-install.in b/util/i386/pc/grub-install.in
index 8ceb811..7850076 100644
--- a/util/i386/pc/grub-install.in
+++ b/util/i386/pc/grub-install.in
@@ -271,6 +271,7 @@ modules="$modules $disk_module"
modules="$modules $fs_module $partmap_module $devabstraction_module"
prefix_drive=
+config=
if [ "x${devabstraction_module}" = "x" ] ; then
if echo "${install_device}" | grep -qx "(.*)" ; then
install_drive="${install_device}"
@@ -289,16 +290,16 @@ if [ "x${devabstraction_module}" = "x" ] ; then
echo "UUID needed with ata mod, but the filesystem containing
${grubdir} does not support UUIDs." 1>&2
exit 1
fi
- prefix_drive="(UUID=${uuid})"
- modules="$modules fs_uuid"
+ config="search_fs_uuid ${uuid} root"
+ modules="$modules search_fs_uuid"
elif [ "x${grub_drive}" != "x${install_drive}" ] ; then
uuid="`$grub_probe --target=fs_uuid --device ${grub_device}`"
if [ "x${uuid}" = "x" ] ; then
echo "You attempted a cross-disk install, but the filesystem
containing ${grubdir} does not support UUIDs." 1>&2
exit 1
fi
- prefix_drive="(UUID=${uuid})"
- modules="$modules fs_uuid"
+ config="search_fs_uuid ${uuid} root"
+ modules="$modules search_fs_uuid"
fi
else
prefix_drive=`$grub_probe --target=drive --device ${grub_device}`
@@ -309,14 +310,20 @@ if [ "x${relative_grubdir}" = "x" ] ; then
relative_grubdir=/
fi
+config_opt=
+echo $config > ${grubdir}/load.cfg
+if [ x$config != x ]; then
+ config_opt="-c $config "
+fi
+
if [ "${target_cpu}-${platform}" = "i386-pc" ] ; then
- $grub_mkimage --output=${grubdir}/core.img
--prefix=${prefix_drive}${relative_grubdir} $modules || exit 1
+ $grub_mkimage ${config_opt} --output=${grubdir}/core.img
--prefix=${prefix_drive}${relative_grubdir} $modules || exit 1
# Now perform the installation.
$grub_setup ${setup_verbose} ${setup_force} --directory=${grubdir}
--device-map=${device_map} \
${install_device} || exit 1
else
- $grub_mkimage -d ${pkglibdir} --output=/boot/multiboot.img
--prefix=${prefix_drive}${relative_grubdir} $modules || exit 1
+ $grub_mkimage ${config_opt} -d ${pkglibdir} --output=/boot/multiboot.img
--prefix=${prefix_drive}${relative_grubdir} $modules || exit 1
fi
# Prompt the user to check if the device map is correct.
Re: Current Grub2 & problem with /boot on different drive, Dean Loros, 2009/09/25
Re: Current Grub2 & problem with /boot on different drive, Dean Loros, 2009/09/25
Re: Current Grub2 & problem with /boot on different drive, Dean Loros, 2009/09/27