Improper handling of --disk-module argument in grub-install

2014-05-18 Thread Glenn Washburn
Currently when using --disk-module=xxx, grub-install will fail with a
message about disk-module not being a valid option.

To fix this, OPTION_MODULE should be removed from the option enum and
the remaining references to OPTION_MODULE (only one) should be renamed
to OPTION_DISK_MODULE.

Glenn

___
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel


Re: How to exit from linux kernel and return to then grub?

2014-05-18 Thread Lennart Sorensen
On Sun, May 18, 2014 at 01:33:15PM +0800, Z C wrote:
> If I boot into a linux kernel using a grub command like "linux /vmlinuz;
> inirtd /initrd; boot", how do I shutdown linux itself (but do not power off
> or reboot the computer hardware) and return back to the grub directly?
> 
> What I meant is something equivalent to the "exit" command in most shells:
> If you are within one shell and you enter another shell, then if you want
> to quit the second shell and return back to the first shell, just simply
> type exit. All env variables and commands you previous typed in the first
> shell are completely intact.
> 
> Suppose I am now in the grub shell, and then I boot into a tiny linux
> kernel, say, a busybox shell, then what can I do to exit the second shell
> (i.e. busybox shell) and return to the first shell (i.e. grub shell)? Of
> course I can enter the grub shell again by simply rebooting the hardware,
> but this is not what I want.

Once linux boots, it does not preserve the boot loader in memory (whyever
would it do that?)

If you want to invent a way to load grub using kexec so you can switch
back to grub fropm a running linux system, well have fun, but why bother?
Where is the use?  It is so hard to deal with what the state of all the
hardware is without doing a reset.

-- 
Len Sorensen

___
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel


Re: How to exit from linux kernel and return to then grub?

2014-05-18 Thread SevenBits
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 05/18/2014 01:33 AM, Z C wrote:
> If I boot into a linux kernel using a grub command like "linux
> /vmlinuz; inirtd /initrd; boot", how do I shutdown linux itself
> (but do not power off or reboot the computer hardware) and return
> back to the grub directly?

You can't.

> 
> What I meant is something equivalent to the "exit" command in most
> shells: If you are within one shell and you enter another shell,
> then if you want to quit the second shell and return back to the
> first shell, just simply type exit. All env variables and commands
> you previous typed in the first shell are completely intact.
> 
> Suppose I am now in the grub shell, and then I boot into a tiny
> linux kernel, say, a busybox shell, then what can I do to exit the
> second shell (i.e. busybox shell) and return to the first shell
> (i.e. grub shell)? Of course I can enter the grub shell again by
> simply rebooting the hardware, but this is not what I want.

When Linux boots, the kernel takes over the management of the computer
completely. The boot loader is not preserved in memory. Why would it
be? The function of the boot loader really is to just boot up the
computer and then get the heck out.

There are many, many obstacles to implementing something like this.
Not to mention the fact that in order to return to GRUB, you would
need to set the processor to return from protected mode into real
mode. All modern processors can do from real mode to protected mode
(which you must do to enabled 32 bit processing).

So, no. It isn't possible.

> 
> 
> 
> ___ Grub-devel mailing
> list Grub-devel@gnu.org 
> https://lists.gnu.org/mailman/listinfo/grub-devel
> 
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.14 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQEcBAEBAgAGBQJTeOrsAAoJEFbRvtGxmFPEkRcIAIXPLokSPvjmBW/1xCVdsOqn
3AP7ZP/IQwNsFvvXUWczpjGDZAZIWSykHdB0zTl7xIYeT9cwEqzgVcZxNnV7riUr
lAKc8viq1ZpZpwR+9k3KOFXzeL63tpNOi2JYaRxnsVHuk/s7ASoDD80KfO+LoqYd
BoJ5XL/yxhYy7EoKkHAElgSQ68RFg3pdix2q4tjN205WvJoP1nfakITyhdiifxLW
Dm7l6LFUv2wn7HWpvJw722UHz6M5/wenXNLZwHejp/561gW+hiKzhT5pTs//p4y/
NOqFrY9W+Q5z8PyIH0AYFDCDmg6Pi04dezEoEGr4c4SFs2N9weMRlVnJpqN48pc=
=rftU
-END PGP SIGNATURE-

___
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel


Re: How to exit from linux kernel and return to then grub?

2014-05-18 Thread SevenBits
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Actually, a correction to what I just said. A processor can return
from protected mode to real mode. Read more here:

https://en.wikipedia.org/wiki/Protected_mode#Entering_and_exiting_protected_mode

I don't know if GRUB supports this (I would assume not) but generally
speaking it is still not possible to do what you want because the
Linux kernel as far as I know does not have the functionality that
would be required. If you want to try and do this, go ahead and
attempt it, but the roadblocks will be so large that it probably is
not worth trying, and just simply rebooting the machine is the best
way to get to GRUB.

If you tell us what are _trying_ to do, i.e what you need this
functionality for, perhaps we can suggest an alternative way to
achieve what you need.

- -- SevenBits

P.S: Since this topic is not about the development of GRUB, it
probably doesn't belong in this list. Please consider posting to
grub-users instead.

On 05/18/2014 01:33 AM, Z C wrote:
> If I boot into a linux kernel using a grub command like "linux
> /vmlinuz; inirtd /initrd; boot", how do I shutdown linux itself
> (but do not power off or reboot the computer hardware) and return
> back to the grub directly?
> 
> What I meant is something equivalent to the "exit" command in most
> shells: If you are within one shell and you enter another shell,
> then if you want to quit the second shell and return back to the
> first shell, just simply type exit. All env variables and commands
> you previous typed in the first shell are completely intact.
> 
> Suppose I am now in the grub shell, and then I boot into a tiny
> linux kernel, say, a busybox shell, then what can I do to exit the
> second shell (i.e. busybox shell) and return to the first shell
> (i.e. grub shell)? Of course I can enter the grub shell again by
> simply rebooting the hardware, but this is not what I want.
> 
> 
> 
> ___ Grub-devel mailing
> list Grub-devel@gnu.org 
> https://lists.gnu.org/mailman/listinfo/grub-devel
> 
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.14 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQEcBAEBAgAGBQJTeOyJAAoJEFbRvtGxmFPEykoH/3cw/hYn+kdJLKrJeTh9SgJy
+2z8KKbPgX5H71NqUUAN7bU5yE+AyAvVh2F8K9PAk1HxVFu3edGD6Wmr4DRnwY6m
i9nS+gnq+5enS/9xj7LHtvuEm/6xbYJkI54i9U6EGYBR6gJneRkd2yoJqmJsKUum
eh7TIjTmrXPW6Kd2ZcoO7GyR/hjR+GWNDQRJeaVmj2wlZM00et+ei3AXzpvOzJ3l
9IOd3gkhkkt77DxYFPkxnJk7HtsHl1rnvqW4ct07ByzlFgCsFo8/ddbgEE6l6Zlm
U1OvndApeofKoznXtNmrMpquHhqnTE9mr8asIua5962s9HdBkxPtHU+4a0VvBYw=
=QTsj
-END PGP SIGNATURE-

___
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel


Re: How to use grub2-extra-lua module

2014-05-18 Thread Vladimir 'φ-coder/phcoder' Serbinenko
On 15.05.2014 15:45, 张驰 wrote:
> I googled for grub2-lua, but found very few information on it. I can't
> find an official website for grub2-lua (i.e official stable source code
> tarball download link), except for a git/bzr clone link.
> 
> Moreover, I can't find any documentation about grub lua. So I don't know
> how to use it.
> 
> I managed to compile grub2 along with lua module, then I boot into grub
> and type "help lua" to try to get some help info. But it only says that
> I can use command "lua script_file.lua" to execute the lua script. So I
> just want to learn the details on how to use lua module. For example,
> how to execute lua commands in grub.cfg file, how to return the lua
> execution result to the grub.cfg file, and what APIs does grub provide
> to the lua module.
> 
> The reason why I want to use lua module is that I have the need of file
> system operations in grub (i.e. mv, cp, cd, pwd, mkdir, rm, nano
> commands). grub2 itself doesn't provide this functionality. Some posts
> said grub-extra-lua module may provide this feature.
> 
GRUB never modifes files except in some very careful ways (env block).
You ask for means rather than end goal. What is your end goal?
> So I just want to know how to use grub lua module to operate on files
> and directories.
> 
> 
> 
> ___
> Grub-devel mailing list
> Grub-devel@gnu.org
> https://lists.gnu.org/mailman/listinfo/grub-devel
> 




signature.asc
Description: OpenPGP digital signature
___
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel


Re: Grub development

2014-05-18 Thread Vladimir 'φ-coder/phcoder' Serbinenko
On 17.05.2014 09:25, r jan wrote:
> I am a student doing project on grub, I am interested in developing
> grub. So please allow me and help me for development of grub. Thankyou
> 
You're extremely vague. Please detail what you want to develop and
what's the usecase and youtr approach to it.
> 
> ___
> Grub-devel mailing list
> Grub-devel@gnu.org
> https://lists.gnu.org/mailman/listinfo/grub-devel
> 




signature.asc
Description: OpenPGP digital signature
___
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel


Re: How to exit from linux kernel and return to then grub?

2014-05-18 Thread Vladimir 'φ-coder/phcoder' Serbinenko
On 18.05.2014 19:16, SevenBits wrote:
> On 05/18/2014 01:33 AM, Z C wrote:
>> If I boot into a linux kernel using a grub command like "linux
>> /vmlinuz; inirtd /initrd; boot", how do I shutdown linux itself
>> (but do not power off or reboot the computer hardware) and return
>> back to the grub directly?
> 
> You can't.
> 
> 
>> What I meant is something equivalent to the "exit" command in most
>> shells: If you are within one shell and you enter another shell,
>> then if you want to quit the second shell and return back to the
>> first shell, just simply type exit. All env variables and commands
>> you previous typed in the first shell are completely intact.
> 
>> Suppose I am now in the grub shell, and then I boot into a tiny
>> linux kernel, say, a busybox shell, then what can I do to exit the
>> second shell (i.e. busybox shell) and return to the first shell
>> (i.e. grub shell)? Of course I can enter the grub shell again by
>> simply rebooting the hardware, but this is not what I want.
> 
> When Linux boots, the kernel takes over the management of the computer
> completely. The boot loader is not preserved in memory. Why would it
> be? The function of the boot loader really is to just boot up the
> computer and then get the heck out.
> 
> There are many, many obstacles to implementing something like this.
> Not to mention the fact that in order to return to GRUB, you would
> need to set the processor to return from protected mode into real
> mode. All modern processors can do from real mode to protected mode
> (which you must do to enabled 32 bit processing).
> 
Please update your sources. Last CPU that behaved like this is 286. 386
and later can switch between modes in any direction.
GRUB itself run in protected (but not paged mode) and switches to real
mode to call BIOS functions.
"Returning" to GRUB would be technically feasible but very cumbersome.
Original requester didn't even tell what his end goal is and it probably
can be achieved in much less cumbersome way.
> So, no. It isn't possible.
> 
> 
> 
> 
>> ___ Grub-devel mailing
>> list Grub-devel@gnu.org 
>> https://lists.gnu.org/mailman/listinfo/grub-devel
> 
> 
> ___
> Grub-devel mailing list
> Grub-devel@gnu.org
> https://lists.gnu.org/mailman/listinfo/grub-devel
> .
> 




signature.asc
Description: OpenPGP digital signature
___
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel


Re: How to exit from linux kernel and return to then grub?

2014-05-18 Thread SevenBits
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 05/18/2014 01:46 PM, Vladimir '?-coder/phcoder' Serbinenko wrote:
> On 18.05.2014 19:16, SevenBits wrote:
>> On 05/18/2014 01:33 AM, Z C wrote:
>>> If I boot into a linux kernel using a grub command like "linux 
>>> /vmlinuz; inirtd /initrd; boot", how do I shutdown linux
>>> itself (but do not power off or reboot the computer hardware)
>>> and return back to the grub directly?
>> 
>> You can't.
>> 
>> 
>>> What I meant is something equivalent to the "exit" command in
>>> most shells: If you are within one shell and you enter another
>>> shell, then if you want to quit the second shell and return
>>> back to the first shell, just simply type exit. All env
>>> variables and commands you previous typed in the first shell
>>> are completely intact.
>> 
>>> Suppose I am now in the grub shell, and then I boot into a
>>> tiny linux kernel, say, a busybox shell, then what can I do to
>>> exit the second shell (i.e. busybox shell) and return to the
>>> first shell (i.e. grub shell)? Of course I can enter the grub
>>> shell again by simply rebooting the hardware, but this is not
>>> what I want.
>> 
>> When Linux boots, the kernel takes over the management of the
>> computer completely. The boot loader is not preserved in memory.
>> Why would it be? The function of the boot loader really is to
>> just boot up the computer and then get the heck out.
>> 
>> There are many, many obstacles to implementing something like
>> this. Not to mention the fact that in order to return to GRUB,
>> you would need to set the processor to return from protected mode
>> into real mode. All modern processors can do from real mode to
>> protected mode (which you must do to enabled 32 bit processing).
>> 
> Please update your sources. Last CPU that behaved like this is 286.
> 386 and later can switch between modes in any direction.

Hi, yes, I actually realized this and posted an addendum to this
message shortly afterwards. I don't know if you received it, but here
is what I wrote:

> Actually, a correction to what I just said. A processor can return 
> from protected mode to real mode. Read more here:
> 
> https://en.wikipedia.org/wiki/Protected_mode#Entering_and_exiting_protected_mode
>
>  I don't know if GRUB supports this (I would assume so) but
> generally speaking it is still not possible to do what you want
> because the Linux kernel as far as I know does not have the
> functionality that would be required. If you want to try and do
> this, go ahead and attempt it, but the roadblocks will be so large
> that it probably is not worth trying, and just simply rebooting the
> machine is the best way to get to GRUB.
> 
> If you tell us what are _trying_ to do, i.e what you need this 
> functionality for, perhaps we can suggest an alternative way to 
> achieve what you need.

So, yes, I realized after I posted my message that what I said was
wrong. My apologies.

> GRUB itself run in protected (but not paged mode) and switches to
> real mode to call BIOS functions. "Returning" to GRUB would be
> technically feasible but very cumbersome. Original requester didn't
> even tell what his end goal is and it probably can be achieved in
> much less cumbersome way.

My thoughts exactly.

>> So, no. It isn't possible.
>> 
>> 
>> 
>> 
>>> ___ Grub-devel
>>> mailing list Grub-devel@gnu.org 
>>> https://lists.gnu.org/mailman/listinfo/grub-devel
>> 
>> 
>> ___ Grub-devel
>> mailing list Grub-devel@gnu.org 
>> https://lists.gnu.org/mailman/listinfo/grub-devel .
>> 
> 
> 
> 
> 
> ___ Grub-devel mailing
> list Grub-devel@gnu.org 
> https://lists.gnu.org/mailman/listinfo/grub-devel
> 
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.14 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQEcBAEBAgAGBQJTePN6AAoJEFbRvtGxmFPE7coH/12UTfimb2bONnDsJY3dFbTu
Ti/xJ85n60fk3DFdCZ03ksqXfzGLjCeMHK8CzyhSCsUr7yFSAgB/9wEnxyc1XDDM
4msE6864xWHlzGSwzGkDyzdbbe0GiPIEGeVbgsnACsSF9JzsC3H08Y6bBF6DOF75
hGkgSJff8Su6oGTZPJpRV99MaKdThjgQkU6B7olOpGSbIzhf6/mrlCfTkJh14bdu
PqsnVcdTSR8xkiZjn5aUGRkXapwl2IE+2jE+lmrFZRWDSRsCggykESa7gMUArCvg
aTd66lj1gex6LmmujT9tsxwewYQnBYZC6JcXQB3KamISaJghPhB8eVvA5Ps3V2I=
=G998
-END PGP SIGNATURE-

___
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel


Re: How to exit from linux kernel and return to then grub?

2014-05-18 Thread Chris Jones
On Sun, May 18, 2014 at 01:33:15AM EDT, Z C wrote:

[..]

> If you are within one shell and you enter another shell, then if you want
> to quit the second shell and return back to the first shell, just simply
> type exit. All env variables and commands you previous typed in the first
> shell are completely intact.

A more valid metaphor would be to start an xterm (or such)... type 'exec
bash'.. type 'exit'... see what happens.

CJ

___
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel


[PATCH] Allow user-defined functions to override builtins.

2014-05-18 Thread Glenn Washburn
Currently, builtin commands take precedence over user-defined
functions.  This patch reverses that precedence, so that users can
"override" builtin commands.  Builtin commands may be accessed by
issuing the command prefixed by an '@' character.

My motivation for this change is to hook insmod in loaded configfiles
which set $prefix to a different location than desired.  If there are
any changes needed to help get this functionality included, please let
me know.

Glenn

---
 grub-core/script/execute.c | 17 +
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/grub-core/script/execute.c b/grub-core/script/execute.c
index afd5513..0769151 100644
--- a/grub-core/script/execute.c
+++ b/grub-core/script/execute.c
@@ -941,14 +941,15 @@ grub_script_execute_cmdline (struct
grub_script_cmd *cmd) args = argv.args + 2;
   cmdname = argv.args[1];
 }
-  grubcmd = grub_command_find (cmdname);
-  if (! grubcmd)
+  /* Allow user functions to override built in commands. */
+  func = grub_script_function_find (cmdname);
+  if (! func)
 {
   grub_errno = GRUB_ERR_NONE;
 
-  /* It's not a GRUB command, try all functions.  */
-  func = grub_script_function_find (cmdname);
-  if (! func)
+  /* It's not a function, check if GRUB command.  */
+  grubcmd = grub_command_find ((cmdname[0] ==
'@')?(cmdname+1):cmdname);
+  if (! grubcmd)
{
  /* As a last resort, try if it is an assignment.  */
  char *assign = grub_strdup (cmdname);
@@ -977,7 +978,9 @@ grub_script_execute_cmdline (struct grub_script_cmd
*cmd) }
 
   /* Execute the GRUB command or function.  */
-  if (grubcmd)
+  if (func)
+ret = grub_script_function_call (func, argc, args);
+  else
 {
   if (grub_extractor_level && !(grubcmd->flags
& GRUB_COMMAND_FLAG_EXTRACTOR))
@@ -990,8 +993,6 @@ grub_script_execute_cmdline (struct grub_script_cmd
*cmd) else
ret = (grubcmd->func) (grubcmd, argc, args);
 }
-  else
-ret = grub_script_function_call (func, argc, args);
 
   if (invert)
 {
-- 
1.8.3.2


___
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel


[PATCH 1/2] Add hidden memdisk option to grub-install.

2014-05-18 Thread Glenn Washburn
I have a set of scripts that I've been using with the old shell script 
grub-install that creates its own memdisk and embedded config.  Those options 
are not available at present (I suspect partly intentionally).  With this in 
mind, I've added these options to grub-install, but left them as hidden 
options.  I'm not opposed to making them visible either.

---
 util/grub-install.c | 12 ++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/util/grub-install.c b/util/grub-install.c
index 7d61c32..d66030f 100644
--- a/util/grub-install.c
+++ b/util/grub-install.c
@@ -70,6 +70,7 @@ static int force = 0;
 static int have_abstractions = 0;
 static int have_cryptodisk = 0;
 static char * bootloader_id;
+static char *memdisk = NULL;
 static int have_load_cfg = 0;
 static FILE * load_cfg_f = NULL;
 static char *load_cfg;
@@ -98,6 +99,7 @@ enum
 OPTION_REMOVABLE, 
 OPTION_BOOTLOADER_ID, 
 OPTION_EFI_DIRECTORY,
+OPTION_MEMDISK,
 OPTION_FONT,
 OPTION_DEBUG,
 OPTION_DEBUG_IMAGE,
@@ -181,6 +183,11 @@ argp_parser (int key, char *arg, struct argp_state *state)
   efidir = xstrdup (arg);
   return 0;
 
+case OPTION_MEMDISK:
+  free (memdisk);
+  memdisk = xstrdup (arg);
+  return 0;
+
 case OPTION_DISK_MODULE:
   free (disk_module);
   disk_module = xstrdup (arg);
@@ -256,6 +263,7 @@ static struct argp_option options[] = {
   {"target", OPTION_TARGET, N_("TARGET"),
/* TRANSLATORS: "TARGET" as in "target platform".  */
0, N_("install GRUB for TARGET platform [default=%s]; available targets: 
%s"), 2},
+  {"memdisk", OPTION_MEMDISK, N_("FILE"), OPTION_HIDDEN, 0, 2},
   {"grub-setup", OPTION_SETUP, "FILE", OPTION_HIDDEN, 0, 2},
   {"grub-mkrelpath", OPTION_MKRELPATH, "FILE", OPTION_HIDDEN, 0, 2},
   {"grub-mkdevicemap", OPTION_MKDEVICEMAP, "FILE", OPTION_HIDDEN, 0, 2},
@@ -1587,7 +1595,7 @@ main (int argc, char *argv[])
   grub_install_make_image_wrap (/* source dir  */ 
grub_install_source_directory,
/*prefix */ prefix,
/* output */ imgfile,
-   /* memdisk */ NULL,
+   /* memdisk */ memdisk,
have_load_cfg ? load_cfg : NULL,
/* image target */ mkimage_target, 0);
   /* Backward-compatibility kludges.  */
@@ -1617,7 +1625,7 @@ main (int argc, char *argv[])
grub_install_make_image_wrap (/* source dir  */ 
grub_install_source_directory,
  /* prefix */ "",
   /* output */ dst,
-  /* memdisk */ NULL,
+  /* memdisk */ memdisk,
  have_load_cfg ? load_cfg : NULL,
   /* image target */ mkimage_target, 0);
   }
-- 
1.8.3.2


___
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel