Browse Source

fixed warnings, renamed funcs & indented

master
Mathieu Serandour 1 year ago
parent
commit
fe00c41f8c
  1. 9
      kernel/entry.c
  2. 13
      kernel/fs/vfs.c
  3. 6
      kernel/fs/vfs.h
  4. 4
      kernel/lib/string.c

9
kernel/entry.c

@ -17,6 +17,7 @@
#include "drivers/pcie/scan.h"
#include "fs/gpt.h"
#include "fs/vfs.h"
#include "memory/gdt.h"
#include "memory/physical_allocator.h"
@ -31,6 +32,7 @@
#include "lib/registers.h"
#include "lib/dump.h"
#include "lib/stacktrace.h"
#include "lib/panic.h"
#include "early_video.h"
@ -230,6 +232,7 @@ void _start(struct stivale2_struct *stivale2_struct) {
hpet_init();
apic_setup_clock();
vfs_init();
pcie_init();
@ -238,9 +241,11 @@ void _start(struct stivale2_struct *stivale2_struct) {
ps2kb_set_event_callback(kbhandler);
disk_part_t* part;// = find_partition(*(GUID*)&boot_volume_tag->part_guid);
disk_part_t* part = find_partition(*(GUID*)&boot_volume_tag->part_guid);
if(part) {
log_info("main partition found");
assert(mount(part, "/fs/"));
}
else {
log_warn(
@ -285,4 +290,4 @@ void _start(struct stivale2_struct *stivale2_struct) {
}
__builtin_unreachable();
}
}

13
kernel/fs/vfs.c

@ -18,7 +18,7 @@ static int is_absolute(const char *path)
return path[0] == '/';
}
void init_vfs(void)
void vfs_init(void)
{
vfs_root.name[0] = 0;
vfs_root.type = DT_DIR;
@ -30,6 +30,7 @@ void init_vfs(void)
vfs_root.fs = NULL;
}
static
dirent_t *find_child(dirent_t *dir, const char *name)
{
if (dir->children == NULL && dir->fs)
@ -75,6 +76,7 @@ static dirent_t *add_dir_entry(
return &dir->children[id];
}
dirent_t *vfs_open_dir(const char *path, int create)
{
assert(is_absolute(path));
@ -114,6 +116,7 @@ dirent_t *vfs_open_dir(const char *path, int create)
return d;
}
static
void log_tree(dirent_t *dir, int level)
{
@ -138,6 +141,7 @@ void log_tree(dirent_t *dir, int level)
// free(children);
}
int mount(disk_part_t *part, const char *path)
{
dirent_t *dir = vfs_open_dir(path, 1);
@ -153,6 +157,8 @@ int mount(disk_part_t *part, const char *path)
return 1;
}
file_handler_t *vfs_open_file(const char *filename)
{
dirent_t *dirent = vfs_open_dir(filename, 0);
@ -188,6 +194,7 @@ file_handler_t *vfs_open_file(const char *filename)
return handler;
}
void vfs_close_file(file_handler_t *handle)
{
@ -199,7 +206,7 @@ void vfs_close_file(file_handler_t *handle)
}
dirent_t *read_dir(dirent_t *dir)
dirent_t* vfs_read_dir(dirent_t *dir)
{
assert(dir->type == DT_DIR);
if (dir->children == NULL && dir->fs)
@ -209,7 +216,7 @@ dirent_t *read_dir(dirent_t *dir)
}
void free_dir(dirent_t *entries)
void vfs_free_dir(dirent_t *entries)
{
(void)entries;
// nothing

6
kernel/fs/vfs.h

@ -63,15 +63,15 @@ dirent_t* vfs_open_dir(const char* path, int create);
* @param dir the directory to read
* @return dirent_t* the new dir->children value
*/
dirent_t* read_dir(dirent_t* dir);
dirent_t* vfs_read_dir(dirent_t* dir);
/**
* @brief free directory entries returned by
* read_dir()
* vfs_read_dir()
*
*/
void free_dir(dirent_t*);
void vfs_free_dir(dirent_t*);
file_handler_t* vfs_open_file(const char* filename);
void vfs_close_file(file_handler_t* handle);

4
kernel/lib/string.c

@ -285,13 +285,11 @@ char* strtok_r(char* restrict str, const char* restrict delim, char** restrict s
if(!ptr)
return NULL;
int delim_size = strlen(delim);
while(1) {
char* next = NULL;
for(const char* dptr = delim; *dptr; dptr++) {
char* n = strchr(ptr, *dptr);
char* n = (char*)strchr(ptr, *dptr);
if(!next)
next = n;

Loading…
Cancel
Save