summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Kendrick (octopus) <rjek@rjek.com>2012-08-30 23:03:15 +0100
committerRob Kendrick (octopus) <rjek@rjek.com>2012-08-30 23:03:15 +0100
commit6606ebd28e30bf44096b29698c197f0444c17a70 (patch)
treeec38f27461138a47478dfb1a60f032f4298e3313
parenta311d27e2eae58879264421a1d1a7fe5e4dc18ba (diff)
parent708ae440e1aa2a4fb6b121d35eb2f031cb092a5a (diff)
downloadluxio-6606ebd28e30bf44096b29698c197f0444c17a70.tar.gz
Merge from Daniel
-rw-r--r--luxio.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/luxio.c b/luxio.c
index 0e418ec..acf8e54 100644
--- a/luxio.c
+++ b/luxio.c
@@ -898,6 +898,43 @@ luxio_link(lua_State *L) /* 5.3.4 */
return 2;
}
+/**% symlink
+ * retval = symlink(oldpath, newpath);
+ * retval, errno = symlink(oldpath, newpath)
+ */
+static int
+luxio_symlink(lua_State *L) /* POSIX.1-2001, Unknown location */
+{
+ const char *oldpath = luaL_checkstring(L, 1);
+ const char *newpath = luaL_checkstring(L, 2);
+
+ lua_pushinteger(L, symlink(oldpath, newpath));
+ lua_pushinteger(L, errno);
+
+ return 2;
+}
+
+/**% readlink
+ * retval, target = readlink(path)
+ * retval, errno = readlink(path)
+ */
+static int
+luxio_readlink(lua_State *L) /* POSIX.1-2001, Unknown location */
+{
+ char buffer[PATH_MAX];
+ ssize_t ret;
+ const char *path = luaL_checkstring(L, 1);
+
+ lua_pushinteger(L, (ret = readlink(path, buffer, PATH_MAX)));
+ if (ret > 0) {
+ lua_pushinteger(L, errno);
+ } else {
+ lua_pushstring(L, buffer);
+ }
+
+ return 2;
+}
+
/**# Special file creation ***************************************************/
/**% mkdir
@@ -2936,6 +2973,8 @@ luxio_functions[] = {
{ "rename", luxio_rename },
{ "link", luxio_link },
{ "unlink", luxio_unlink },
+ { "symlink", luxio_symlink },
+ { "readlink", luxio_readlink },
#ifdef HAVE_SENDFILE
{ "sendfile", luxio_sendfile },
#endif