fix file pointers

This commit is contained in:
Murphy 2025-04-04 12:39:47 -04:00
parent a86b7eaf9e
commit 2dc54d9238
Signed by: freya
GPG key ID: 9FBC6FFD6D2DBF17
2 changed files with 15 additions and 6 deletions
kernel
fs
include/comus

View file

@ -43,18 +43,20 @@ struct file_system *fs_get_root_file_system(void)
return NULL;
}
struct file *fs_find_file_abs(struct file_system *fs, char *abs_path)
int fs_find_file_abs(struct file_system *fs, char *abs_path, struct file *res)
{
(void)fs;
(void)abs_path;
(void)res;
panic("fs_find_file_abs NOT YET IMPLEMENTED");
}
struct file *fs_find_file_rel(struct file *rel, char *rel_path)
int fs_find_file_rel(struct file *rel, char *rel_path, struct file *res)
{
(void)rel;
(void)rel_path;
(void)res;
panic("fs_find_file_rel NOT YET IMPLEMENTED");
}

View file

@ -59,6 +59,9 @@ enum file_type {
F_SYM = 2,
};
/// TODO: file name queue or storage area???
/// hash map?!? (performance !!! :) )
struct file {
/// name of the file
char name[MAX_FILE_NAME_LEN];
@ -121,7 +124,7 @@ struct file_system {
/// @param parent - the parent (directory) of the file to create
/// @param type - the type of file to create
/// @returns 0 on success, or an negative fs error code on failure
int (*fs_new_file)(struct file_system *fs, struct file **res,
int (*fs_new_file)(struct file_system *fs, struct file *res,
struct file *parent, enum file_type type);
/// get files in a directory
/// @param fs - the file system
@ -131,7 +134,7 @@ struct file_system {
/// @param res - the list of structures to save into
/// @returns number of entries read, or an negative fs error code on failure
int (*fs_get_dir_ents)(struct file_system *fs, struct file *dir,
size_t start, size_t len, struct file **res);
size_t start, size_t len, struct file res[]);
/// read from a file
/// @param fs - the file system
/// @param file - the file to read from
@ -183,8 +186,10 @@ struct file_system *fs_get_root_file_system(void);
*
* @param fs - the file system to search
* @param name - the absolute path of the file to look for
* @param res - where to store the file structure
* @returns 0 on success, or an negative fs error code on failure
*/
struct file *fs_find_file_abs(struct file_system *fs, char *abs_path);
int fs_find_file_abs(struct file_system *fs, char *abs_path, struct file *res);
/**
* Find a file in the given file system, traversing the path, relative to
@ -193,8 +198,10 @@ struct file *fs_find_file_abs(struct file_system *fs, char *abs_path);
*
* @param rel - the relative file to search from
* @param name - the absolute path of the file to look for
* @param res - where to store the file structure
* @returns 0 on success, or an negative fs error code on failure
*/
struct file *fs_find_file_rel(struct file *rel, char *rel_path);
int fs_find_file_rel(struct file *rel, char *rel_path, struct file *res);
// NOTE: fell free to add more functions if needed :)