Skip to contentSkip to conversation

configfile

PATCH In review Hollis Blanchard 3 participants 10 messages Feb 13, 2005 – Feb 14, 2005

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 configfile

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 <[email protected]>

* 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

i386-pc.rmk +2 -1
diff -u -p -r1.25 i386-pc.rmk
@@ -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

powerpc-ieee1275.rmk +2 -1
diff -u -p -r1.23 powerpc-ieee1275.rmk
@@ -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
configfile.c new file +69 -0

69 lines not on this page · raw message

#1 lore raw
Quoted 2 lines · Hollis Blanchard

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

#2 lore raw
In reply to Hollis Blanchard
Quoted 5 lines · Hollis Blanchard

2005-02-13 Hollis Blanchard <[email protected]>

* 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?

Quoted 2 lines

While working on setting prefix correctly, I found it useful to have the `configfile' command like GRUB Legacy.

Great! :)

Quoted 2 lines
configfile.c new file +0 -0

[...]

configfile.c line 36

Quoted 10 lines
configfile.c new file +10 -0
+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

#3 lore raw
Quoted 5 lines · Marco Gerards

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

#4 lore raw
In reply to Marco Gerards
Quoted 3 lines · Marco Gerards

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

#5 lore raw
Quoted 6 lines · Yoshinori K. Okuji
Quoted 3 lines · Marco Gerards

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

#6 lore raw
Quoted 2 lines · Marco Gerards

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

#7 lore raw
Quoted 9 lines · Yoshinori K. Okuji
Quoted 2 lines · Marco Gerards

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

#8 lore raw
Quoted 4 lines · Marco Gerards

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

#9 lore raw
Quoted 5 lines · Yoshinori K. Okuji

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