[syslinux:master] lua: initramfs: enable adding nonempty files
syslinux-bot for Ferenc Wágner
wferi at niif.hu
Sat Feb 14 11:09:28 PST 2015
Commit-ID: d643cc061c7b2af4e49363f83abbb12eb162fadf
Gitweb: http://www.syslinux.org/commit/d643cc061c7b2af4e49363f83abbb12eb162fadf
Author: Ferenc Wágner <wferi at niif.hu>
AuthorDate: Mon, 13 Oct 2014 00:44:41 +0200
Committer: Ferenc Wágner <wferi at niif.hu>
CommitDate: Mon, 13 Oct 2014 10:45:19 +0200
lua: initramfs: enable adding nonempty files
Signed-off-by: Ferenc Wágner <wferi at niif.hu>
---
com32/lua/src/syslinux.c | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/com32/lua/src/syslinux.c b/com32/lua/src/syslinux.c
index fa23647..18934e1 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;
}
More information about the Syslinux-commits
mailing list