mirror of
https://github.com/kenshineto/kern.git
synced 2025-04-21 12:47:25 +00:00
fix fs vtable
This commit is contained in:
parent
b6e1e94060
commit
d1c61416fc
1 changed files with 28 additions and 10 deletions
|
@ -85,60 +85,78 @@ struct file_system {
|
|||
/// the disk this filesystem is hooked up to
|
||||
struct disk disk;
|
||||
/// get root file in file file_system
|
||||
/// @param fs - the file system
|
||||
/// @returns the root file or NULL on failure
|
||||
struct file *(*fs_get_root_file)(void);
|
||||
struct file *(*fs_get_root_file)(struct file_system *fs);
|
||||
/// rename a file
|
||||
/// @param fs - the file system
|
||||
/// @param file - the file to rename
|
||||
/// @param name - the new file name
|
||||
/// @returns 0 on success, or an negative fs error code on failure
|
||||
int (*fs_rename_file)(struct file *file, char *name);
|
||||
int (*fs_rename_file)(struct file_system *fs, struct file *file,
|
||||
char *name);
|
||||
/// get length of file
|
||||
/// @param fs - the file system
|
||||
/// @param file - the file to get the length of
|
||||
/// @param length - the pointer to save the length to
|
||||
/// @return 0 on success, or an negative fs error code on failure
|
||||
int (*fs_get_file_length)(struct file *file, uint64_t *length);
|
||||
int (*fs_get_file_length)(struct file_system *fs, struct file *file,
|
||||
uint64_t *length);
|
||||
/// get created date of file
|
||||
/// @param fs - the file system
|
||||
/// @param file - the file to get the date created
|
||||
/// @param created - the pointer to save the created date to
|
||||
/// @param modified - the pointer to save the modified date to
|
||||
/// @param accessed - the pointer to save the accessed date to
|
||||
/// @return 0 on success, or an negative fs error code on failure
|
||||
int (*fs_get_file_dates)(struct file *file, uint64_t *created, uint64_t *modified, uint64_t *accessed);
|
||||
int (*fs_get_file_dates)(struct file_system *fs, struct file *file,
|
||||
uint64_t *created, uint64_t *modified,
|
||||
uint64_t *accessed);
|
||||
/// delete a file in the file system
|
||||
/// @param fs - the file system
|
||||
/// @param file - the file to delete
|
||||
/// @returns 0 on success, or an negative fs error code on failure
|
||||
int (*fs_delete_file)(struct file *file);
|
||||
int (*fs_delete_file)(struct file_system *fs, struct file *file);
|
||||
/// create a file with a given name and type
|
||||
/// @param fs - the file system
|
||||
/// @param res - the new file structure to save the new file into
|
||||
/// @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 **res, struct file *parent, enum file_type type);
|
||||
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
|
||||
/// @param dir - the directory to search into
|
||||
/// @param start - the directory entry to start at
|
||||
/// @param len - the max number of entrys to save starting at `start`
|
||||
/// @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 *dir, size_t start, size_t len, struct file **res);
|
||||
int (*fs_get_dir_ents)(struct file_system *fs, struct file *dir,
|
||||
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
|
||||
/// @param offset - the offset of the file to read into
|
||||
/// @param length - the length of the file to read starting at `offset`
|
||||
/// @param buffer - the buffer to save the data into
|
||||
/// @returns number of bytes read, or an negative fs error code on failure
|
||||
int (*fs_read_file)(struct file *file, size_t offset, size_t length, uint8_t *buffer);
|
||||
int (*fs_read_file)(struct file_system *fs, struct file *file,
|
||||
size_t offset, size_t length, uint8_t *buffer);
|
||||
/// write into a file
|
||||
/// @param fs - the file system
|
||||
/// @param file - the file to write to
|
||||
/// @param offset - the offset of the file to write into
|
||||
/// @param length - the length of the data to write
|
||||
/// @param buffer - the buffer the data to write is stored in
|
||||
/// @returns number of bytes written, or an negative fs error code on failure
|
||||
int (*fs_write_file)(struct file *file, size_t offset, size_t length, uint8_t *buffer);
|
||||
int (*fs_write_file)(struct file_system *fs, struct file *file,
|
||||
size_t offset, size_t length, uint8_t *buffer);
|
||||
/// close a file in the filesystem
|
||||
/// @param fs - the file system
|
||||
/// @param file - the file to close
|
||||
/// @returns 0 on success, or an negative fs error coude on failure
|
||||
int (*fs_close_file)(struct file *file);
|
||||
int (*fs_close_file)(struct file_system *fs, struct file *file);
|
||||
};
|
||||
|
||||
// list of all disks on the system
|
||||
|
|
Loading…
Add table
Reference in a new issue