grub-devel
[Top][All Lists]
Advanced

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

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


From: Fajar A. Nugraha
Subject: Re: [PATCH] v2: grub-extras/lua: add fs label to grub.enum_device
Date: Mon, 2 Mar 2015 15:52:18 +0700

changes from v1: add *label NULL check

This patch modifies grub_lib.c to add fs label as fourth return value
to grub.enum_device. This can be used on osdetect.lua to create OS
description that is easier to understand, as well as providing pool
names for root-on-zfs setup.

Patch inline and attached. Indentation might look weird do to mixed
use of tab and space (mostly copied from current fs uuid code). Is
there a preference for either style? Should I convert all tabs to
spaces at least for this patch?

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-03-02 15:10:14.007284753 +0700
@@ -183,7 +183,34 @@
  }
     }

-  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
+ {
+  if (label == NULL)
+    {
+      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]