[syslinux] [PATCH 0/2] improve Lua API for files and initramfs objects

Paul Emmerich P.Emmerich at first-colo.net
Thu Nov 10 04:38:58 PST 2016


Hi,

> Ferenc Wágner <wferi at niif.hu>:
> for reading configuration files from disk.  Does it not work with HTTP/
> TFTP for you?  Using that, load_file could be implemented in Lua as:

that does work, yes. It just looked like a file object should have a some way
to get the contents. I'm actually not using it in our scripts.


> All in all, I can't see the need for new bindings for this task, but
> maybe I miss something.  At the same time, file:data() might
> occasionally come useful.

initramfs:load_file() is basically a memory optimization over your solution.
It calls initramfs_load_file() directly, this loads the file exactly once into memory.

Going through a Lua string loads the file, then copies it into a (interned) Lua string,
then copies this string again in initramfs:add_file(). This doubles the peak memory usage
(might even triple it if you are not freeing the file before passing it into add_file)

This is a concern for our setup: we load relatively large wimboot images and
support relatively small VMs at the same time.


 Paul




More information about the Syslinux mailing list