Source code for the Trusted Boot Module.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
tbm-mcu/include/mufs.h

64 lines
1.6 KiB

#pragma once
#include <stdint.h>
struct flash_dev;
struct mufs;
struct mufs_dir;
struct mufs_file;
struct mufs_tree {
struct mufs *fs;
uint32_t va;
uint32_t file_size;
uint32_t root;
uint8_t depth;
};
struct mufs {
struct mufs_tree root;
struct flash_dev *dev;
uint32_t nblocks;
uint8_t log2_nentries;
};
struct mufs_dirent {
char path[256];
struct mufs_tree tree;
uint8_t type;
};
struct mufs_stat {
uint8_t type;
uint32_t file_size;
};
#define MUFS_READ BIT(0)
#define MUFS_WRITE BIT(1)
#define MUFS_APPEND BIT(2)
#define MUFS_FILE BIT(0)
#define MUFS_DIR BIT(1)
struct mufs *mufs_mount(struct flash_dev *dev);
void mufs_unmount(struct mufs *fs);
int mufs_format(struct flash_dev *dev);
char *mufs_abspath(const char *path);
int mufs_stat(struct mufs *fs, const char *path, struct mufs_stat *stat);
int mufs_rename(struct mufs *fs, const char *old, const char *new);
struct mufs_dir *mufs_opendir(struct mufs *fs, const char *path);
void mufs_closedir(struct mufs_dir *dir);
int mufs_readdir(struct mufs_dir *dir, struct mufs_dirent *dirent);
int mufs_mkdir(struct mufs *fs, const char *path);
int mufs_rmdir(struct mufs *fs, const char *path);
int mufs_create(struct mufs *fs, const char *path);
struct mufs_file *mufs_open(struct mufs *fs, const char *path, int mode);
void mufs_close(struct mufs_file *file);
long mufs_seek(struct mufs_file *file, long offset, int whence);
size_t mufs_read(struct mufs_file *file, void *data, size_t len);
size_t mufs_write(struct mufs_file *file, const void *data, size_t len);
int mufs_unlink(struct mufs *fs, const char *path);