blob: 28a5929d3b4041c883d3fb4932dd248253a8a592 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
#include <stdint.h>
#include <kernel/fs/vfs.h>
#include <kernel/fs/ext2.h>
#include <kernel/lib/stdlib.h>
#include <kernel/memory/alloc.h>
#include <kernel/system.h>
uint32_t sys_write(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);
fs_open(node);
if (node->inode != 0) {
uint32_t size = ((struct ext2_file *)node->impl)->inode.size;
fs_write(node, 0, size, buf);
buf[size - 1] = '\0';
fs_close(node);
return size;
} else {
fs_close(node);
return -1;
}
}
|