summaryrefslogtreecommitdiff
path: root/kernel/syscalls/write.c
blob: 80c6e577463f6e03e01cd36f97c39e9ab4b7d794 (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);
  if (!fd_ptr) {
    return -EBADF;
  }
  int rc = vfs_pwrite(fd, (char *)buf, count, fd_ptr->offset);
  fd_ptr->offset += rc;
  return rc;
}