summaryrefslogtreecommitdiff
path: root/src/libc/camellia.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/libc/camellia.c')
-rw-r--r--src/libc/camellia.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/libc/camellia.c b/src/libc/camellia.c
new file mode 100644
index 0000000..4e092e4
--- /dev/null
+++ b/src/libc/camellia.c
@@ -0,0 +1,30 @@
+#include <camellia.h>
+#include <camellia/syscalls.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+hid_t camellia_open(const char *path, int flags) {
+ hid_t ret;
+ char *buf;
+ size_t len;
+
+ if (path == NULL)
+ return errno = EINVAL, -EINVAL;
+ if (flags & OPEN_CREATE)
+ flags |= OPEN_WRITE;
+
+ len = absolutepath(NULL, path, 0);
+ buf = malloc(len);
+ if (!buf)
+ return -errno;
+ absolutepath(buf, path, len);
+ ret = _sys_open(buf, strlen(buf), flags);
+ free(buf);
+
+ if (ret < 0)
+ errno = -ret;
+
+ return ret;
+}