summaryrefslogtreecommitdiff
path: root/kernel/syscalls/write.c
blob: ef8a46fa9cfa4abcb00ab812457414efc96dbbfe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
#include <errno.h>
#include <fs/vfs.h>
#include <syscalls.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;
}