* [patch] configfile
@ 2005-02-13 15:18 Hollis Blanchard
2005-02-13 16:03 ` Yoshinori K. Okuji
2005-02-13 17:53 ` Marco Gerards
0 siblings, 2 replies; 10+ messages in thread
From: Hollis Blanchard @ 2005-02-13 15:18 UTC (permalink / raw)
To: grub-devel
While working on setting prefix correctly, I found it useful to have the
`configfile' command like GRUB Legacy.
I haven't tested on i386. I'm not sure about the `nested' parameter to
grub_normal_execute, but this code seems to be working fine.
2005-02-13 Hollis Blanchard <hollis@penguinppc.org>
* conf/i386-pc.rmk (pkgdata_MODULES): Add configfile.mod.
* conf/powerpc-ieee1275.rmk (pkgdata_MODULES): Likewise.
* commands/configfile.mod: New file.
Index: conf/i386-pc.rmk
===================================================================
RCS file: /cvsroot/grub/grub2/conf/i386-pc.rmk,v
retrieving revision 1.25
diff -u -p -r1.25 i386-pc.rmk
--- conf/i386-pc.rmk 31 Jan 2005 21:40:25 -0000 1.25
+++ conf/i386-pc.rmk 13 Feb 2005 15:39:37 -0000
@@ -84,7 +84,8 @@ genmoddep_SOURCES = util/genmoddep.c
pkgdata_MODULES = _chain.mod _linux.mod linux.mod fat.mod ufs.mod ext2.mod minix.mod \
hfs.mod jfs.mod normal.mod hello.mod vga.mod font.mod _multiboot.mod ls.mod \
boot.mod cmp.mod cat.mod terminal.mod fshelp.mod chain.mod multiboot.mod \
- amiga.mod apple.mod pc.mod loopback.mod reboot.mod halt.mod help.mod
+ amiga.mod apple.mod pc.mod loopback.mod reboot.mod halt.mod help.mod \
+ configfile.mod
# For _chain.mod.
_chain_mod_SOURCES = loader/i386/pc/chainloader.c
Index: conf/powerpc-ieee1275.rmk
===================================================================
RCS file: /cvsroot/grub/grub2/conf/powerpc-ieee1275.rmk,v
retrieving revision 1.23
diff -u -p -r1.23 powerpc-ieee1275.rmk
--- conf/powerpc-ieee1275.rmk 31 Jan 2005 21:40:25 -0000 1.23
+++ conf/powerpc-ieee1275.rmk 13 Feb 2005 15:39:37 -0000
@@ -65,7 +65,8 @@ genmoddep_SOURCES = util/genmoddep.c
pkgdata_MODULES = _linux.mod linux.mod fat.mod ufs.mod ext2.mod minix.mod \
hfs.mod jfs.mod normal.mod hello.mod font.mod \
boot.mod cmp.mod cat.mod terminal.mod fshelp.mod amiga.mod apple.mod \
- pc.mod suspend.mod loopback.mod help.mod reboot.mod halt.mod
+ pc.mod suspend.mod loopback.mod help.mod reboot.mod halt.mod \
+ configfile.mod
# For fshelp.mod.
fshelp_mod_SOURCES = fs/fshelp.c
--- /dev/null 2004-12-18 12:15:49.000000000 -0600
+++ commands/configfile.c 2005-02-13 09:11:41.166390400 -0600
@@ -0,0 +1,69 @@
+/* configfile.c - command to manually load config file */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2005 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 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <grub/normal.h>
+#include <grub/dl.h>
+#include <grub/arg.h>
+#include <grub/term.h>
+#include <grub/misc.h>
+
+static grub_err_t
+grub_cmd_configfile (struct grub_arg_list *state __attribute__ ((unused)),
+ int argc, char **args)
+
+{
+ if (argc != 1)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, "file name required");
+
+ grub_cls ();
+ grub_normal_execute (args[0], 1);
+
+ return 0;
+}
+
+\f
+#ifdef GRUB_UTIL
+void
+grub_configfile_init (void)
+{
+ grub_register_command ("configfile", grub_cmd_configfile,
+ GRUB_COMMAND_FLAG_BOTH, "configfile FILE",
+ "Load config file", 0);
+}
+
+void
+grub_configfile_fini (void)
+{
+ grub_unregister_command ("configfile");
+}
+#else /* ! GRUB_UTIL */
+GRUB_MOD_INIT
+{
+ (void)mod; /* To stop warning. */
+ grub_register_command ("configfile", grub_cmd_configfile,
+ GRUB_COMMAND_FLAG_BOTH, "configfile FILE",
+ "Load config file", 0);
+}
+
+GRUB_MOD_FINI
+{
+ grub_unregister_command ("configfile");
+}
+#endif /* ! GRUB_UTIL */
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: [patch] configfile
2005-02-13 15:18 [patch] configfile Hollis Blanchard
@ 2005-02-13 16:03 ` Yoshinori K. Okuji
2005-02-13 17:53 ` Marco Gerards
1 sibling, 0 replies; 10+ messages in thread
From: Yoshinori K. Okuji @ 2005-02-13 16:03 UTC (permalink / raw)
To: The development of GRUB 2
On Sunday 13 February 2005 16:18, Hollis Blanchard wrote:
> I haven't tested on i386. I'm not sure about the `nested' parameter
> to grub_normal_execute, but this code seems to be working fine.
If NESTED is non-zero, the menu and the command-line interface should
display a bit different messages and you should be able to go back to
previous configuration by pressing ESC. I really don't know if this
works well or not...
Okuji
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [patch] configfile
2005-02-13 15:18 [patch] configfile Hollis Blanchard
2005-02-13 16:03 ` Yoshinori K. Okuji
@ 2005-02-13 17:53 ` Marco Gerards
2005-02-13 18:49 ` Yoshinori K. Okuji
2005-02-13 18:52 ` Hollis Blanchard
1 sibling, 2 replies; 10+ messages in thread
From: Marco Gerards @ 2005-02-13 17:53 UTC (permalink / raw)
To: The development of GRUB 2
Hollis Blanchard <hollis@penguinppc.org> writes:
> 2005-02-13 Hollis Blanchard <hollis@penguinppc.org>
>
> * conf/i386-pc.rmk (pkgdata_MODULES): Add configfile.mod.
> * conf/powerpc-ieee1275.rmk (pkgdata_MODULES): Likewise.
> * commands/configfile.mod: New file.
Could you please add it to grub-emu as well?
> While working on setting prefix correctly, I found it useful to have the
> `configfile' command like GRUB Legacy.
Great! :)
> --- /dev/null 2004-12-18 12:15:49.000000000 -0600
> +++ commands/configfile.c 2005-02-13 09:11:41.166390400 -0600
[...]
> +static grub_err_t
> +grub_cmd_configfile (struct grub_arg_list *state __attribute__ ((unused)),
> + int argc, char **args)
> +
> +{
> + if (argc != 1)
> + return grub_error (GRUB_ERR_BAD_ARGUMENT, "file name required");
> +
> + grub_cls ();
> + grub_normal_execute (args[0], 1);
When this is called from normal mode, by running a command this means
that another normal mode will be started again. If you run this
command a few times, you would see a lot normal modes running when
examining the stack, right?
This is the main reason I have not implemented this command yet. To
me it would seem better to update the data in the already running
normal mode.
Please correct me if I am wrong.
Thanks,
Marco
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: [patch] configfile
2005-02-13 17:53 ` Marco Gerards
@ 2005-02-13 18:49 ` Yoshinori K. Okuji
2005-02-13 19:41 ` Marco Gerards
2005-02-13 18:52 ` Hollis Blanchard
1 sibling, 1 reply; 10+ messages in thread
From: Yoshinori K. Okuji @ 2005-02-13 18:49 UTC (permalink / raw)
To: The development of GRUB 2
On Sunday 13 February 2005 18:53, Marco Gerards wrote:
> This is the main reason I have not implemented this command yet. To
> me it would seem better to update the data in the already running
> normal mode.
Why? Are you afraid of memory exhaustion?
Okuji
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [patch] configfile
2005-02-13 18:49 ` Yoshinori K. Okuji
@ 2005-02-13 19:41 ` Marco Gerards
2005-02-13 20:36 ` Yoshinori K. Okuji
0 siblings, 1 reply; 10+ messages in thread
From: Marco Gerards @ 2005-02-13 19:41 UTC (permalink / raw)
To: The development of GRUB 2
"Yoshinori K. Okuji" <okuji@enbug.org> writes:
> On Sunday 13 February 2005 18:53, Marco Gerards wrote:
>> This is the main reason I have not implemented this command yet. To
>> me it would seem better to update the data in the already running
>> normal mode.
>
> Why? Are you afraid of memory exhaustion?
It just seems it a bit awkward to me. I have no idea how big the
stack is on the PC and if it will cause problems.
If you think it is ok, fine for me.
Thanks,
Marco
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [patch] configfile
2005-02-13 19:41 ` Marco Gerards
@ 2005-02-13 20:36 ` Yoshinori K. Okuji
2005-02-14 19:20 ` Marco Gerards
0 siblings, 1 reply; 10+ messages in thread
From: Yoshinori K. Okuji @ 2005-02-13 20:36 UTC (permalink / raw)
To: The development of GRUB 2
On Sunday 13 February 2005 20:41, Marco Gerards wrote:
> It just seems it a bit awkward to me. I have no idea how big the
> stack is on the PC and if it will cause problems.
I don't know, either, but I guess it would consume less than 1KB per
configfile, because large data is allocated on the heap but not on the
stack. If you don't like it, it is feasible to push the context of
current configuration and call longjmp to start a new configuration. I
think this is tricky.
Okuji
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [patch] configfile
2005-02-13 20:36 ` Yoshinori K. Okuji
@ 2005-02-14 19:20 ` Marco Gerards
2005-02-14 20:54 ` Yoshinori K. Okuji
0 siblings, 1 reply; 10+ messages in thread
From: Marco Gerards @ 2005-02-14 19:20 UTC (permalink / raw)
To: The development of GRUB 2
"Yoshinori K. Okuji" <okuji@enbug.org> writes:
> On Sunday 13 February 2005 20:41, Marco Gerards wrote:
>> It just seems it a bit awkward to me. I have no idea how big the
>> stack is on the PC and if it will cause problems.
>
> I don't know, either, but I guess it would consume less than 1KB per
> configfile, because large data is allocated on the heap but not on the
> stack. If you don't like it, it is feasible to push the context of
> current configuration and call longjmp to start a new configuration. I
> think this is tricky.
What I had in mind was to change the menu in memory. But I don't have
any problems with a few lost bytes either. So we just do it like in
Hollis' patch? In that case I'll review so it can be applied.
--
Marco
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [patch] configfile
2005-02-14 19:20 ` Marco Gerards
@ 2005-02-14 20:54 ` Yoshinori K. Okuji
2005-02-14 21:03 ` Yoshinori K. Okuji
0 siblings, 1 reply; 10+ messages in thread
From: Yoshinori K. Okuji @ 2005-02-14 20:54 UTC (permalink / raw)
To: The development of GRUB 2
On Monday 14 February 2005 20:20, Marco Gerards wrote:
> What I had in mind was to change the menu in memory. But I don't
> have any problems with a few lost bytes either. So we just do it
> like in Hollis' patch? In that case I'll review so it can be
> applied.
I checked how much memory was consumed with grub-emu. I loaded a config
file and executed a command to show a stack pointer on the command-line
interface, then I reloaded the same config file and did the same
command. The result was 0xbffff184 and 0xbffff074. The difference is
272 in decimal. So I think this is negligible.
Okuji
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [patch] configfile
2005-02-14 20:54 ` Yoshinori K. Okuji
@ 2005-02-14 21:03 ` Yoshinori K. Okuji
0 siblings, 0 replies; 10+ messages in thread
From: Yoshinori K. Okuji @ 2005-02-14 21:03 UTC (permalink / raw)
To: The development of GRUB 2
On Monday 14 February 2005 21:54, Yoshinori K. Okuji wrote:
> I checked how much memory was consumed with grub-emu. I loaded a
> config file and executed a command to show a stack pointer on the
> command-line interface, then I reloaded the same config file and did
> the same command. The result was 0xbffff184 and 0xbffff074. The
> difference is 272 in decimal. So I think this is negligible.
I forgot to report a bug in the patch. When I go back to the
command-line interface by pressing ESC, the display is not refreshed.
I'm not sure how to fix this cleanly.
Okuji
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [patch] configfile
2005-02-13 17:53 ` Marco Gerards
2005-02-13 18:49 ` Yoshinori K. Okuji
@ 2005-02-13 18:52 ` Hollis Blanchard
1 sibling, 0 replies; 10+ messages in thread
From: Hollis Blanchard @ 2005-02-13 18:52 UTC (permalink / raw)
To: The development of GRUB 2
On Feb 13, 2005, at 11:53 AM, Marco Gerards wrote:
>
> When this is called from normal mode, by running a command this means
> that another normal mode will be started again. If you run this
> command a few times, you would see a lot normal modes running when
> examining the stack, right?
Hmm, I think you're right.
However, right now there is no single "menu" that could be replaced,
just the one(s) created in grub_normal_execute. I guess that will need
to be restructured before a "configfile" command will work. Too bad.
-Hollis
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2005-02-14 21:21 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-02-13 15:18 [patch] configfile Hollis Blanchard
2005-02-13 16:03 ` Yoshinori K. Okuji
2005-02-13 17:53 ` Marco Gerards
2005-02-13 18:49 ` Yoshinori K. Okuji
2005-02-13 19:41 ` Marco Gerards
2005-02-13 20:36 ` Yoshinori K. Okuji
2005-02-14 19:20 ` Marco Gerards
2005-02-14 20:54 ` Yoshinori K. Okuji
2005-02-14 21:03 ` Yoshinori K. Okuji
2005-02-13 18:52 ` Hollis Blanchard
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.