* How to use grub2-extra-lua module
@ 2014-05-15 13:45 张驰
2014-05-15 22:53 ` Geoffrey Thomas
2014-05-18 17:39 ` Vladimir 'φ-coder/phcoder' Serbinenko
0 siblings, 2 replies; 3+ messages in thread
From: 张驰 @ 2014-05-15 13:45 UTC (permalink / raw)
To: grub-devel
[-- Attachment #1: Type: text/plain, Size: 1084 bytes --]
I googled for grub2-lua, but found very few information on it. I can't find
an official website for grub2-lua (i.e official stable source code tarball
download link), except for a git/bzr clone link.
Moreover, I can't find any documentation about grub lua. So I don't know
how to use it.
I managed to compile grub2 along with lua module, then I boot into grub and
type "help lua" to try to get some help info. But it only says that I can
use command "lua script_file.lua" to execute the lua script. So I just want
to learn the details on how to use lua module. For example, how to execute
lua commands in grub.cfg file, how to return the lua execution result to
the grub.cfg file, and what APIs does grub provide to the lua module.
The reason why I want to use lua module is that I have the need of file
system operations in grub (i.e. mv, cp, cd, pwd, mkdir, rm, nano commands).
grub2 itself doesn't provide this functionality. Some posts said
grub-extra-lua module may provide this feature.
So I just want to know how to use grub lua module to operate on files and
directories.
[-- Attachment #2: Type: text/html, Size: 2332 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: How to use grub2-extra-lua module
2014-05-15 13:45 How to use grub2-extra-lua module 张驰
@ 2014-05-15 22:53 ` Geoffrey Thomas
2014-05-18 17:39 ` Vladimir 'φ-coder/phcoder' Serbinenko
1 sibling, 0 replies; 3+ messages in thread
From: Geoffrey Thomas @ 2014-05-15 22:53 UTC (permalink / raw)
To: The development of GNU GRUB
[-- Attachment #1: Type: text/plain, Size: 2394 bytes --]
On Thu, 15 May 2014, 张驰 wrote:
> I googled for grub2-lua, but found very few information on it. I can't
> find an official website for grub2-lua (i.e official stable source code
> tarball download link), except for a git/bzr clone link.
>
> Moreover, I can't find any documentation about grub lua. So I don't know
> how to use it.
>
> I managed to compile grub2 along with lua module, then I boot into grub
> and type "help lua" to try to get some help info. But it only says that
> I can use command "lua script_file.lua" to execute the lua script. So I
> just want to learn the details on how to use lua module. For example,
> how to execute lua commands in grub.cfg file, how to return the lua
> execution result to the grub.cfg file, and what APIs does grub provide
> to the lua module.
>
> The reason why I want to use lua module is that I have the need of file
> system operations in grub (i.e. mv, cp, cd, pwd, mkdir, rm, nano
> commands). grub2 itself doesn't provide this functionality. Some posts
> said grub-extra-lua module may provide this feature.
>
> So I just want to know how to use grub lua module to operate on files
> and directories.
Take a look at the grub_lua_lib array at the bottom of grub_lib.h. Those
functions are accessible in the "grub" library. Any GRUB command can be
accessed via grub.run; for instance, grub.run("boot") will boot the loaded
kernel. Many GRUB commands have return values, which are returned from
grub.run.
You can use the grub.file_* functions for opening files. For instance, you
can write local f = grub.file_open("/boot/myfile.txt", "r") to get a file
handle, and then call grub.file_getline(f) to read lines from the file.
GRUB generally tries to avoid writing to disks, mostly because safely
writing to disks is much harder than safely reading from them, especially
if an fsck is needed. So you're probably not going to get mv, cp, rm, etc.
If you need to set persistent settings, you may be interested in the
environment block functionality. You can read and write variables via
grub.getenv and grub.setenv, and load and store the enviornment block via
grub.run("load_env") and grub.run("save_env"). See
http://www.gnu.org/software/grub/manual/html_node/Environment-block.html
for more details.
Hope this helps,
--
Geoffrey Thomas
gthomas@mokafive.com
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: How to use grub2-extra-lua module
2014-05-15 13:45 How to use grub2-extra-lua module 张驰
2014-05-15 22:53 ` Geoffrey Thomas
@ 2014-05-18 17:39 ` Vladimir 'φ-coder/phcoder' Serbinenko
1 sibling, 0 replies; 3+ messages in thread
From: Vladimir 'φ-coder/phcoder' Serbinenko @ 2014-05-18 17:39 UTC (permalink / raw)
To: The development of GNU GRUB
[-- Attachment #1: Type: text/plain, Size: 1495 bytes --]
On 15.05.2014 15:45, 张驰 wrote:
> I googled for grub2-lua, but found very few information on it. I can't
> find an official website for grub2-lua (i.e official stable source code
> tarball download link), except for a git/bzr clone link.
>
> Moreover, I can't find any documentation about grub lua. So I don't know
> how to use it.
>
> I managed to compile grub2 along with lua module, then I boot into grub
> and type "help lua" to try to get some help info. But it only says that
> I can use command "lua script_file.lua" to execute the lua script. So I
> just want to learn the details on how to use lua module. For example,
> how to execute lua commands in grub.cfg file, how to return the lua
> execution result to the grub.cfg file, and what APIs does grub provide
> to the lua module.
>
> The reason why I want to use lua module is that I have the need of file
> system operations in grub (i.e. mv, cp, cd, pwd, mkdir, rm, nano
> commands). grub2 itself doesn't provide this functionality. Some posts
> said grub-extra-lua module may provide this feature.
>
GRUB never modifes files except in some very careful ways (env block).
You ask for means rather than end goal. What is your end goal?
> So I just want to know how to use grub lua module to operate on files
> and directories.
>
>
>
> _______________________________________________
> Grub-devel mailing list
> Grub-devel@gnu.org
> https://lists.gnu.org/mailman/listinfo/grub-devel
>
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 274 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-05-18 17:39 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-15 13:45 How to use grub2-extra-lua module 张驰
2014-05-15 22:53 ` Geoffrey Thomas
2014-05-18 17:39 ` Vladimir 'φ-coder/phcoder' Serbinenko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).