From e83dca9817614d0dc77ce1e5dc13eed44b61eb2f Mon Sep 17 00:00:00 2001 From: dzwdz Date: Tue, 4 Oct 2022 13:59:21 +0200 Subject: user/libc: camellia_open, takes cwd into account --- src/user/lib/camellia.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 src/user/lib/camellia.c (limited to 'src/user/lib/camellia.c') diff --git a/src/user/lib/camellia.c b/src/user/lib/camellia.c new file mode 100644 index 0000000..1aa8402 --- /dev/null +++ b/src/user/lib/camellia.c @@ -0,0 +1,30 @@ +#include +#include +#include +#include +#include +#include + +handle_t camellia_open(const char *path, int flags) { + handle_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 = _syscall_open(buf, strlen(buf), flags); + free(buf); + + if (ret < 0) + errno = -ret; + + return ret; +} -- cgit v1.2.3