From 4a56e2c2cc3d78f12f1788c27669a651071dee49 Mon Sep 17 00:00:00 2001 From: "Fajar A. Nugraha" Date: Fri, 27 Mar 2015 14:57:28 +0100 Subject: [PATCH] grub-extras/lua: add fs label to grub.enum_device --- lua/grub_lib.c | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/lua/grub_lib.c b/lua/grub_lib.c index 7798a20..3d25d02 100644 --- a/lua/grub_lib.c +++ b/lua/grub_lib.c @@ -183,7 +183,34 @@ grub_lua_enum_device_iter (const char *name, void *data) } } - lua_call (state, 3, 1); + if (! fs->label) + lua_pushnil (state); + else + { + int err; + char *label = NULL; + + 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); } -- 2.11.4.GIT