syscall: implement write syscall

This commit is contained in:
Michael Shaw 2023-11-22 23:27:39 -05:00
commit 3dda839cdd
12 changed files with 176 additions and 22 deletions

View file

@ -11,6 +11,7 @@
#define ENOSPC 7
#define EEXIST 8
#define ENOEXEC 9
#define EFAULT 10
const char *strerror(int errnum);

View file

@ -80,7 +80,9 @@ struct file_descriptor {
uint32_t mode;
char *buf;
size_t buf_size;
size_t buf_len;
int (*buf_write)(struct file_descriptor *fdesc, void *buf, size_t count);
int (*buf_read)(struct file_descriptor *fdesc, void *buf, size_t count);
struct fs *fs;
};
@ -126,4 +128,6 @@ char *dirname(char *path);
struct file_descriptor *fd_special();
void fd_special_free(struct file_descriptor *fd);
int stdout_write(struct file_descriptor *fdesc, void *buf, size_t len);
#endif /* _VFS_H_ */

View file

@ -11,6 +11,10 @@
#define PROC_STOPPED 1
#define PROC_BLOCKED 2
#define STDIN_FILENO 0
#define STDOUT_FILENO 1
#define STDERR_FILENO 2
typedef int64_t pid_t;
struct procregs {
@ -44,6 +48,7 @@ struct proc {
uint64_t pid;
uint64_t ppid;
uint64_t cr3;
spinlock_t lock;
bool is_kernel;
uint8_t state;

9
include/kernel/syscall.h Normal file
View file

@ -0,0 +1,9 @@
/* SPDX-License-Identifier: GPL-2.0-only */
#ifndef _SYSCALL_H_
#define _SYSCALL_H_
#define SYS_READ 0
#define SYS_WRITE 1
#define SYS_EXIT 60
#endif /* _SYSCALL_H_ */