Adding a new file system¶
This section describes the common interface provided by any filesystem.
API¶
Typedefs
-
typedef struct file_system file_system_t¶
Functions
-
int fs_register(struct fs_ops *fops)¶
Registers a new filesystem interface.
- Parameters:
fops – filesystem operations table
- Returns:
0 on success, non-zero on failure
-
const struct fs_ops *fs_ops_try_unique(void)¶
Will look for the number of registered filesystems and will return the fops if there is only one.
- Returns:
fops if there’s only one registered filesystem, NULL otherwise.
-
const struct fs_ops *fs_ops_from_container(struct fops_container *container)¶
-
int fs_mount(const file_system_t *fs, const char *path)¶
Mount file system.
- Parameters:
fs – - file system to mount
path – - path to mount i.e. 0:, nffs:
- Returns:
0 on success
-
const file_system_t *fs_unmount_mount_point(const char *mount_point)¶
Unmount file system by mount point.
- Parameters:
mount_point – - mount point to unmount i.e. 0:, nffs:
- Returns:
0 on success
-
int fs_unmount_file_system(const file_system_t *fs)¶
Unmount file system.
- Parameters:
fs – - mounted file system to unmount
- Returns:
0 on success
-
const char *file_system_path(const char *path, const file_system_t **fs)¶
Get file system mount point path.
For given path it will return mount point and file system i.e.: For 0:/DIREC/FIL.TXT function will return “0:” and fs will be filled with pointer to valid file_system_t structure.
- Parameters:
path – - file or directory name
fs – - on success file system
- Returns:
file system mount point string
-
const file_system_t *get_only_file_system(void)¶
Return the only file system mounted.
It there is only one file system mounted it will be returned by this function. If two file system were mounted funciton will return NULL.
- Returns:
non-NULL if exactly one file system is mounted, otherwise NULL
-
void get_file_system_path(const char *path, const file_system_t **fs, const char **fs_path)¶
Get file system and file system mount point.
Usually
- Parameters:
path – - file system path
fs – - file system for path
fs_path – - mount point (usually prefix of file path)
-
struct file_system¶
- #include <fs_if.h>
-
struct mount_point¶
- #include <fs_if.h>
-
struct fs_ops¶
- #include <fs_if.h>
Public Members
-
int (*f_open)(const char *filename, uint8_t access_flags, struct fs_file **out_file)¶
-
int (*f_close)(struct fs_file *file)¶
-
int (*f_read)(struct fs_file *file, uint32_t len, void *out_data, uint32_t *out_len)¶
-
int (*f_write)(struct fs_file *file, const void *data, int len)¶
-
int (*f_flush)(struct fs_file *file)¶
-
int (*f_seek)(struct fs_file *file, uint32_t offset)¶
-
uint32_t (*f_getpos)(const struct fs_file *file)¶
-
int (*f_filelen)(const struct fs_file *file, uint32_t *out_len)¶
-
int (*f_unlink)(const char *filename)¶
-
int (*f_rename)(const char *from, const char *to)¶
-
int (*f_mkdir)(const char *path)¶
-
int (*f_opendir)(const char *path, struct fs_dir **out_dir)¶
-
int (*f_readdir)(struct fs_dir *dir, struct fs_dirent **out_dirent)¶
-
int (*f_closedir)(struct fs_dir *dir)¶
-
int (*f_dirent_name)(const struct fs_dirent *dirent, size_t max_len, char *out_name, uint8_t *out_name_len)¶
-
int (*f_dirent_is_dir)(const struct fs_dirent *dirent)¶
-
int (*f_mount)(const file_system_t *fs)¶
-
int (*f_umount)(const file_system_t *fs)¶
-
int (*f_open)(const char *filename, uint8_t access_flags, struct fs_file **out_file)¶
-
struct fops_container¶
- #include <fs_if.h>