summaryrefslogtreecommitdiff
path: root/kernel/syscalls/write.c
blob: f88215de66cf29b7902085c9327f0b165f51073c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
#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, NULL);
  if (!fd_ptr) {
    return -EBADF;
  }
  int rc = vfs_pwrite(fd, (char *)buf, count, fd_ptr->offset);
  fd_ptr->offset += rc;
  return rc;
}