summaryrefslogtreecommitdiff
path: root/luxio.c
diff options
context:
space:
mode:
authorRob Kendrick (humdrum) <rjek@rjek.com>2012-05-01 13:21:30 +0100
committerRob Kendrick (humdrum) <rjek@rjek.com>2012-05-01 13:21:30 +0100
commit80f2a14a42dfff407f87e09e05d816d8d6adf90d (patch)
treee85a31ea71e4b30663f44a98c7347cff6072dc5c /luxio.c
parentc03a9d5ca256e89f89fe59d8b30a0b93c2fee844 (diff)
downloadluxio-80f2a14a42dfff407f87e09e05d816d8d6adf90d.tar.gz
Bind chmod() and fchmod()
Diffstat (limited to 'luxio.c')
-rw-r--r--luxio.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/luxio.c b/luxio.c
index 212afcb..72a220a 100644
--- a/luxio.c
+++ b/luxio.c
@@ -346,6 +346,30 @@ luxio_umask(lua_State *L)
return 1;
}
+static int
+luxio_chmod(lua_State *L)
+{
+ const char *path = luaL_checkstring(L, 1);
+ mode_t mode = luaL_checkinteger(L, 2);
+
+ lua_pushinteger(L, chmod(path, mode));
+ lua_pushinteger(L, errno);
+
+ return 2;
+}
+
+static int
+luxio_fchmod(lua_State *L)
+{
+ int fd = luaL_checkinteger(L, 1);
+ mode_t mode = luaL_checkinteger(L, 2);
+
+ lua_pushinteger(L, fchmod(fd, mode));
+ lua_pushinteger(L, errno);
+
+ return 2;
+}
+
#define LUXIO_SOCKADDR_METATABLE_NAME "luxio.sockaddr"
#ifndef UNIX_PATH_MAX
/* From man 7 unix */
@@ -1590,6 +1614,8 @@ luxio_functions[] = {
#endif
{ "fcntl", luxio_fcntl },
{ "umask", luxio_umask },
+ { "chmod", luxio_chmod },
+ { "fchmod", luxio_fchmod },
{ "mkfifo", luxio_mkfifo },
{ "socket", luxio_socket },