feat(iso): modified fd struct and func proto

This commit is contained in:
Malo Lecomte 2022-04-24 02:17:53 +02:00
parent 1daa8e6263
commit 04bbb27df6
2 changed files with 7 additions and 5 deletions

7
k/fd.c
View File

@ -1,6 +1,6 @@
#include "fd.h"
static struct file_entry fd_table[MAX_FD] = { 0 };
struct file_entry fd_table[MAX_FD] = { 0 };
static int find_next_fd(void)
{
@ -13,14 +13,13 @@ static int find_next_fd(void)
return -1;
}
int register_fd(u32 lba, u32 file_size)
int register_fd(u32 lba, u32 file_size, u8 is_dir)
{
int free_fd = find_next_fd();
if (free_fd < 0)
return -1;
struct file_entry f = { .open = 0, .lba = lba, .file_offset = 0,
.file_size = file_size };
struct file_entry f = { 0, lba, 0, file_size, is_dir };
fd_table[free_fd] = f;
return free_fd;
}

5
k/fd.h
View File

@ -11,9 +11,12 @@ struct file_entry
u32 lba;
u32 file_offset;
u32 file_size;
u8 is_dir;
};
int register_fd(u32 lba, u32 file_size);
extern struct file_entry fd_table[MAX_FD];
int register_fd(u32 lba, u32 file_size, u8 is_dir);
int destroy_fd(int fd);
#endif /* !FD_H */