Thu 05 May 2011 09:35:22 AM UTC, original submission:
It should be possible to execute the embedded config file in "normal mode"
I have been investigating grub for several hours just now and have been able to implement the feature.
There is, though, of course more than one way to do it. Grub is NOT lacking concepts and levels of abstraction.
The basic "problem" is that "normal mode" relies on files. Functions in grub-core/normal/main.c expect file paths.
The way I approached the task was basically to move the grub_load_config() function from kern/main.c to normal/main.c and duplicate some functions in normal/main.c to make them accept char* buffers instead of grub_file_t as arguments. It works nicely so far. But is not compatible with the current behavior.
I have 2 possibilities how to proceed now and would like to know which would have more chances to be included in the trunk.
1. write a module which basically does the same like kern/main.c does. The module would provide a special function that would "take over" control from kern/main.c as soon as it gets called from the embedded config file. The embedded config config file would then start with
embedded_normal
or something like that and the module would switch mode and never return control to kern/main.c
2. adjust kern/main.c and normal/main.c and make grub switch to "normal mode" in case
normal
is called from an embedded config file and NOT load (prefix)/grub.cfg. If "normal" is not called, switch to normal mode and load /grub.cfg, just like before.
Method 2 would use significantly less code I think. Should I give it a try? (I actually don't really have the time anytime soon anyway... :-) maybe somebody else would like doing it as well... )
Thoughts??
|