Files
freywaros/src/kernel/fs.h
T

35 lines
815 B
C

#pragma once
#include "src/kernel/stream.h"
#define FILENAME_SIZE_LIMIT 255
typedef struct fs_node {
uint8_t type;
uint32_t refs;
char name[FILENAME_SIZE_LIMIT + 1];
uint32_t size;
uint8_t is_dir;
uint8_t removed;
} fs_node_t;
fs_node_t *fs_open_root();
fs_node_t *fs_open_by(const fs_node_t *directory, const char *name, uint64_t flags);
fs_node_t *fs_open_at(const fs_node_t *directory, uint16_t index, uint64_t flags);
fs_node_t *fs_open_again(fs_node_t *source);
stream_t *fs_open_stream(fs_node_t *source);
void fs_read(const fs_node_t *file, uint32_t offset, uint32_t bytes, void *to);
void fs_write(fs_node_t *file, uint32_t offset, const void *from, uint32_t bytes);
void fs_truncate(fs_node_t *file, uint32_t size);
void fs_remove(fs_node_t *file);
void fs_close(fs_node_t *node);