diff options
author | Marvin Borner | 2020-05-02 15:44:11 +0200 |
---|---|---|
committer | Marvin Borner | 2020-05-02 15:44:11 +0200 |
commit | aa8a8811818331cf511681327e3ba95e456f0d33 (patch) | |
tree | 852c314dae76e756863f94639ff45eff72834d5d /src/kernel/syscall/actions/sys_read.c | |
parent | 2a0e810a473dea57fd1cd53ea424b61269c029ba (diff) |
Added many syscalls to get better POSIX compliance
Diffstat (limited to 'src/kernel/syscall/actions/sys_read.c')
-rw-r--r-- | src/kernel/syscall/actions/sys_read.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/kernel/syscall/actions/sys_read.c b/src/kernel/syscall/actions/sys_read.c new file mode 100644 index 0000000..a954f56 --- /dev/null +++ b/src/kernel/syscall/actions/sys_read.c @@ -0,0 +1,22 @@ +#include <stdint.h> +#include <kernel/fs/vfs.h> +#include <kernel/fs/ext2.h> +#include <kernel/lib/stdlib.h> +#include <kernel/memory/alloc.h> + +uint32_t sys_read(char *path, uint32_t offset, uint32_t count, char *buf) +{ + struct fs_node *node = (struct fs_node *)umalloc(sizeof(struct fs_node)); + strcpy(node->name, path); + ext2_root->open(node); + if (node->inode != 0) { + uint32_t size = ((struct ext2_file *)node->impl)->inode.size; + ext2_root->read(node, 0, size, buf); + buf[size - 1] = '\0'; + ext2_root->close(node); + return size; + } else { + ext2_root->close(node); + return -1; + } +}
\ No newline at end of file |