From: Tobias Ulmer Date: Tue, 8 Oct 2013 12:25:40 +0000 (+0200) Subject: Add chmod function X-Git-Tag: e2factory-2.3.15rc1~451 X-Git-Url: https://git.e2factory.org/?a=commitdiff_plain;h=222c9256e1d9a16e23c236dd27455aa524ed5bc4;p=e2factory.git Add chmod function Signed-off-by: Tobias Ulmer --- diff --git a/generic/le2lib.c b/generic/le2lib.c index 5a76abd..0d958e5 100644 --- a/generic/le2lib.c +++ b/generic/le2lib.c @@ -738,6 +738,22 @@ do_uname_machine(lua_State *lua) return 1; } +static int +do_chmod(lua_State *L) +{ + const char *path = luaL_checkstring(L, 1); + mode_t mode = luaL_checkinteger(L, 2); + + if (chmod(path, mode) != 0) { + lua_pushboolean(L, 0); + lua_pushstring(L, strerror(errno)); + + return 2; + } + + lua_pushboolean(L, 1); + return 1; +} /* * Hook that gets called once an interrupt has been requested. @@ -780,6 +796,7 @@ laction(int i) { static luaL_Reg lib[] = { { "chdir", change_directory }, + { "chmod", do_chmod }, { "closefrom", closefrom }, { "cwd", get_working_directory }, { "directory", get_directory },