grub-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] grub-extras/lua: add fs label to grub.enum_device


From: Fajar A. Nugraha
Subject: [PATCH] grub-extras/lua: add fs label to grub.enum_device
Date: Fri, 27 Feb 2015 18:47:32 +0700

The original mail, in case it didn't get through (because I used the
wrong sender address):

On Fri, Feb 27, 2015 at 3:41 PM, Fajar A. Nugraha <address@hidden> wrote:
>
> Hi,
>
> Is this the right place to ask about possible enhancement to grub-lua?
>
> I'm looking to modify osdetect.lua with the ability to boot
> ubuntu-on-zfs setup. Most of the needed capabilities are already
> there. However I can't find how to get pool name from a device. Grub
> is already able to detect the pool name as label, and it shows up
> correctly when I use "probe -l". Would you be open to modifying
> grub_lib.c so that grub.enum_device will also pass fs label to the
> callback function (currently it pass device, fs, and uuid)?
>
> Or alternatively, in case I missed something obvious, is there a way
> capture the output of "probe -l" and use it on lua? grub.run only
> returns error code and error message.
>


And now for the patch. It's inline below (also attached, in case my
mail client mess this up), created against grub-extras master
(5d12c95d), tested on grub master (66b0e664). The new lua module was
tested by loading both the original osdetect.lua (enum_device (device,
fs, uuid)) and my modified version (function enum_device (device, fs,
uuid, label)), both run fine and the fs label was correctly populated
on my modified version.

diff -Naru grub-extras-master.orig/lua/grub_lib.c
grub-extras-master/lua/grub_lib.c
--- grub-extras-master.orig/lua/grub_lib.c 2013-12-25 01:06:47.000000000 +0700
+++ grub-extras-master/lua/grub_lib.c 2015-02-27 18:15:33.002264978 +0700
@@ -183,7 +183,27 @@
  }
     }

-  lua_call (state, 3, 1);
+  if (! fs->label)
+    lua_pushnil (state);
+  else
+    {
+      int err;
+      char *label;
+
+      err = fs->label (dev, &label);
+      if (err)
+ {
+  grub_errno = 0;
+  lua_pushnil (state);
+ }
+      else
+ {
+  lua_pushstring (state, label);
+  grub_free (label);
+ }
+    }
+
+  lua_call (state, 4, 1);
   result = lua_tointeger (state, -1);
   lua_pop (state, 1);
  }

Attachment: lua_enum_device.patch
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]