aboutsummaryrefslogtreecommitdiffstats
path: root/com32/lua
diff options
context:
space:
mode:
authorFerenc Wágner <wferi@niif.hu>2014-10-13 00:44:41 +0200
committerFerenc Wágner <wferi@niif.hu>2014-10-13 10:45:19 +0200
commitd643cc061c7b2af4e49363f83abbb12eb162fadf (patch)
tree906cdc108d1bc33dd5f5e3a7c18b59658678ef08 /com32/lua
parent681b0775572467bfa0b8987eec130b4e2b984296 (diff)
downloadsyslinux-d643cc061c7b2af4e49363f83abbb12eb162fadf.tar.gz
syslinux-d643cc061c7b2af4e49363f83abbb12eb162fadf.tar.xz
syslinux-d643cc061c7b2af4e49363f83abbb12eb162fadf.zip
lua: initramfs: enable adding nonempty files
Signed-off-by: Ferenc Wágner <wferi@niif.hu>
Diffstat (limited to 'com32/lua')
-rw-r--r--com32/lua/src/syslinux.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/com32/lua/src/syslinux.c b/com32/lua/src/syslinux.c
index fa236470..18934e18 100644
--- a/com32/lua/src/syslinux.c
+++ b/com32/lua/src/syslinux.c
@@ -302,11 +302,18 @@ static int sl_initramfs_load_archive(lua_State * L)
static int sl_initramfs_add_file(lua_State * L)
{
const char *filename = luaL_checkstring(L, 2);
- void *file_data = NULL;
- size_t file_len = 0;
-
+ size_t file_len;
+ const char *file_data = luaL_optlstring (L, 3, NULL, &file_len);
+ void *data = NULL;
+
+ if (file_len) {
+ data = malloc (file_len);
+ if (!data) return luaL_error (L, "Out of memory");
+ memcpy (data, file_data, file_len);
+ }
if (initramfs_add_file(luaL_checkudata(L, 1, SYSLINUX_INITRAMFS),
- file_data, file_len, file_len, filename, 0, 0755))
+ data, file_len, file_len, filename,
+ luaL_optint (L, 4, 0), luaL_optint (L, 5, 0755)))
return luaL_error (L, "Adding file %s to initramfs failed", filename);
return 0;
}