Adding a new file system

This section describes the common interface provided by any filesystem.

API

Functions

int fs_register(struct fs_ops *fops)

Registers a new filesystem interface.

Return

0 on success, non-zero on failure

Parameters
  • fops: filesystem operations table

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.

Return

fops if there’s only one registered filesystem, NULL otherwise.

struct fs_ops *fs_ops_for(const char *name)

Retrieve a filesystem’s operations table.

Return

valid pointer on success, NULL on failure

Parameters
  • name: Name of the filesystem to retrieve fs_ops for

struct fs_ops *fs_ops_from_container(struct fops_container *container)
struct fs_ops
#include <fs_if.h>

Public Functions

SLIST_ENTRY (fs_ops) sc_next

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_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)
const char *f_name
struct fops_container
#include <fs_if.h>

Public Members

struct fs_ops *fops