Skip to contentSkip to conversation

Don't abort if prefix is not set

PATCH In review Pavel Roskin 3 participants 7 messages Jan 26, 2008 – Jan 27, 2008

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Don't abort if prefix is not set

---

 ChangeLog |    5 +++++
 kern/dl.c |    6 ++++--
 2 files changed, 9 insertions(+), 2 deletions(-)
ChangeLog +5 -0
index 009b4dc..44d5887 100644
@@ -1,3 +1,8 @@
+2008-01-26  Pavel Roskin  <[email protected]>
+
+	* kern/dl.c (grub_dl_load): Don't abort if prefix is not set,
+	just return an error.
+
 2008-01-26  Bean  <[email protected]>
 
 	* fs/reiserfs.c (grub_fshelp_node): New member next_offset.
kern/dl.c +4 -2
index d3488fb..9e8c24a 100644
@@ -625,8 +625,10 @@ grub_dl_load (const char *name)
   if (mod)
     return mod;
   
-  if (! grub_dl_dir)
-    grub_fatal ("module dir is not initialized yet");
+  if (! grub_dl_dir) {
+    grub_error (GRUB_ERR_FILE_NOT_FOUND, "\"prefix\" is not set");
+    return 0;
+  }
 
   filename = (char *) grub_malloc (grub_strlen (grub_dl_dir) + 1
 				   + grub_strlen (name) + 4 + 1);
#1 lore raw
Quoted 25 lines · Pavel Roskin

---

 ChangeLog |    5 +++++
 kern/dl.c |    6 ++++--
 2 files changed, 9 insertions(+), 2 deletions(-)
ChangeLog +5 -0
index 009b4dc..44d5887 100644
@@ -1,3 +1,8 @@
+2008-01-26  Pavel Roskin  <[email protected]>
+
+	* kern/dl.c (grub_dl_load): Don't abort if prefix is not set,
+	just return an error.
+
 2008-01-26  Bean  <[email protected]>
 
 	* fs/reiserfs.c (grub_fshelp_node): New member next_offset.
kern/dl.c +0 -0
index d3488fb..9e8c24a 100644

kern/dl.c grub_dl_load (const char *name) · line 630

Quoted 8 lines
kern/dl.c +3 -2
@@ -625,8 +625,10 @@ grub_dl_load (const char *name)
   if (mod)
     return mod;
 
-  if (! grub_dl_dir)
-    grub_fatal ("module dir is not initialized yet");
+  if (! grub_dl_dir) {
+    grub_error (GRUB_ERR_FILE_NOT_FOUND, "\"prefix\" is not set");
+    return 0;

Seems fine, but are you sure this error is handled somewhere?

Signature · 5 lines
Robert Millan

<GPLv2> I know my rights; I want my phone call!
<DRM> What use is a phone call… if you are unable to speak?
(as seen on /.)
#2 lore raw

Quoting Robert Millan <[email protected]>:

Quoted 5 lines

kern/dl.c grub_dl_load (const char *name) · line 630

Quoted 3 lines
kern/dl.c +3 -0
+  if (! grub_dl_dir) {
+    grub_error (GRUB_ERR_FILE_NOT_FOUND, "\"prefix\" is not set");
+    return 0;

Seems fine, but are you sure this error is handled somewhere?

If prefix is not set, the module is not loaded. What other handling do we need?

I found that prefix would not be set on PowerPC if /memory/available is missing. Even though I have a better workaround for it now, I still think that aborting for such minor reason is wrong. After all, the user may unset prefix.

Signature · 2 lines
Regards,
Pavel Roskin
#3 lore raw
Quoted 10 lines · Pavel Roskin

Quoting Robert Millan <[email protected]>:

Quoted 5 lines

kern/dl.c grub_dl_load (const char *name) · line 630

Quoted 3 lines
kern/dl.c +3 -0
+  if (! grub_dl_dir) {
+    grub_error (GRUB_ERR_FILE_NOT_FOUND, "\"prefix\" is not set");
+    return 0;

Seems fine, but are you sure this error is handled somewhere?

If prefix is not set, the module is not loaded. What other handling do we need?

What I mean is, is the error message printed? I recall it had to be handled somewhere. Or maybe I'm confused...

Quoted 2 lines

I found that prefix would not be set on PowerPC if /memory/available is missing.

Sounds strange.. how is that so?

Quoted 3 lines

Even though I have a better workaround for it now, I
still think that aborting for such minor reason is wrong. After all, the user may unset prefix.

Agreed..

Signature · 5 lines
Robert Millan

<GPLv2> I know my rights; I want my phone call!
<DRM> What use is a phone call… if you are unable to speak?
(as seen on /.)
#4 lore raw

Quoting Robert Millan <[email protected]>:

Quoted 7 lines · Pavel Roskin
Quoted 6 lines

Quoting Robert Millan <[email protected]>:

Quoted 4 lines
Quoted 3 lines
kern/dl.c +3 -0
+  if (! grub_dl_dir) {
+    grub_error (GRUB_ERR_FILE_NOT_FOUND, "\"prefix\" is not set");
+    return 0;
Quoted 7 lines
Quoted 4 lines
Quoted 1 line

Seems fine, but are you sure this error is handled somewhere?

If prefix is not set, the module is not loaded. What other handling do we need?

What I mean is, is the error message printed? I recall it had to be handled somewhere. Or maybe I'm confused...

It's printed. Tested with grub-emu and in qemu.

Quoted 4 lines
Quoted 2 lines

I found that prefix would not be set on PowerPC if /memory/available is missing.

Sounds strange.. how is that so?

Because the environment is allocated in the heap, I believe.

Quoted 5 lines
Quoted 3 lines

Even though I have a better workaround for it now, I
still think that aborting for such minor reason is wrong. After all, the user may unset prefix.

Agreed..

Applying.

Signature · 2 lines
Regards,
Pavel Roskin
#5 lore raw
Quoted 6 lines · Pavel Roskin
Quoted 4 lines
Quoted 2 lines

I found that prefix would not be set on PowerPC if /memory/available is missing.

Sounds strange.. how is that so?

Because the environment is allocated in the heap, I believe.

It is, but I'd have expected GRUB to issue grub_fatal() when this happens. :-/

Signature · 5 lines
Robert Millan

<GPLv2> I know my rights; I want my phone call!
<DRM> What use is a phone call… if you are unable to speak?
(as seen on /.)
#6 lore raw
In reply to Robert Millan
Quoted 11 lines · Robert Millan
Quoted 7 lines · Pavel Roskin

Quoting Robert Millan <[email protected]>:

Quoted 4 lines

kern/dl.c grub_dl_load (const char *name) · line 630

Quoted 3 lines
kern/dl.c +3 -0
+  if (! grub_dl_dir) {
+    grub_error (GRUB_ERR_FILE_NOT_FOUND, "\"prefix\" is not set");
+    return 0;

Seems fine, but are you sure this error is handled somewhere?

If prefix is not set, the module is not loaded. What other handling do we need?

What I mean is, is the error message printed? I recall it had to be handled somewhere. Or maybe I'm confused...

Whole error stack is printed just before prompt.