A update
This commit is contained in:
53
include/fs/ramfs.h
Normal file
53
include/fs/ramfs.h
Normal file
@ -0,0 +1,53 @@
|
||||
#ifndef _RAM_FS_H
|
||||
#define _RAM_FS_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
|
||||
#define RAMFS_MAX_FILES 128
|
||||
#define RAMFS_BLOCK_SIZE 4096
|
||||
#define RAMFS_MAX_PATH_LEN 255
|
||||
|
||||
#define RAMFS_PERM_READ 0x01
|
||||
#define RAMFS_PERM_WRITE 0x02
|
||||
#define RAMFS_PERM_EXEC 0x04
|
||||
#define RAMFS_PERM_ALL (RAMFS_PERM_READ | RAMFS_PERM_WRITE | RAMFS_PERM_EXEC)
|
||||
|
||||
typedef struct ramfs_file {
|
||||
char name[RAMFS_MAX_PATH_LEN];
|
||||
uint32_t size;
|
||||
uint8_t* data;
|
||||
uint8_t permissions;
|
||||
} ramfs_file_t;
|
||||
|
||||
typedef struct ramfs_directory {
|
||||
char name[RAMFS_MAX_PATH_LEN];
|
||||
ramfs_file_t* files[RAMFS_MAX_FILES];
|
||||
uint32_t file_count;
|
||||
} ramfs_directory_t;
|
||||
|
||||
|
||||
void ramfs_init();
|
||||
|
||||
ramfs_file_t* ramfs_create_file(const char* name, uint32_t size, uint8_t permissions);
|
||||
bool ramfs_delete_file(const char* name);
|
||||
ramfs_file_t* ramfs_find_file(const char* name);
|
||||
|
||||
bool ramfs_create_directory(const char* name);
|
||||
bool ramfs_delete_directory(const char* name);
|
||||
|
||||
bool ramfs_check_permissions(const char* name, uint8_t required_permissions);
|
||||
|
||||
bool ramfs_resize_file(const char* name, uint32_t new_size);
|
||||
bool ramfs_append_to_file(const char* name, const uint8_t* data, uint32_t data_size);
|
||||
|
||||
bool ramfs_read_file(const char* name, uint8_t* buffer, uint32_t buffer_size);
|
||||
bool ramfs_write_file(const char* name, const uint8_t* data, uint32_t size);
|
||||
bool ramfs_overwrite_file(const char* name, const uint8_t* data, uint32_t size);
|
||||
|
||||
|
||||
void ramfs_list_files();
|
||||
void ramfs_list_directories();
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user