summaryrefslogtreecommitdiff
path: root/kernel/syscalls/write.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/syscalls/write.c')
-rw-r--r--kernel/syscalls/write.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/kernel/syscalls/write.c b/kernel/syscalls/write.c
new file mode 100644
index 0000000..bdd3927
--- /dev/null
+++ b/kernel/syscalls/write.c
@@ -0,0 +1,12 @@
+#include <fs/vfs.h>
+#include <syscalls.h>
+#include <errno.h>
+
+int syscall_write(int fd, const char *buf, size_t count) {
+ vfs_fd_t *fd_ptr = get_vfs_fd(fd);
+ if (!fd_ptr)
+ return -EBADF;
+ int rc = vfs_pwrite(fd, (char *)buf, count, fd_ptr->offset);
+ fd_ptr->offset += rc;
+ return rc;
+}