MAX3267X LittleFS demo
lfs.c File Reference
#include "lfs.h"
#include "lfs_util.h"

Data Structures

struct  lfs_mattr
 
struct  lfs_diskoff
 
struct  lfs_dir_find_match
 
struct  lfs_commit
 
struct  lfs_dir_commit_commit
 
struct  lfs_fs_parent_match
 

Macros

#define LFS_BLOCK_NULL   ((lfs_block_t)-1)
 
#define LFS_BLOCK_INLINE   ((lfs_block_t)-2)
 
#define LFS_MKTAG(type, id, size)    (((lfs_tag_t)(type) << 20) | ((lfs_tag_t)(id) << 10) | (lfs_tag_t)(size))
 
#define LFS_MKTAG_IF(cond, type, id, size)    ((cond) ? LFS_MKTAG(type, id, size) : LFS_MKTAG(LFS_FROM_NOOP, 0, 0))
 
#define LFS_MKTAG_IF_ELSE(cond, type1, id1, size1, type2, id2, size2)    ((cond) ? LFS_MKTAG(type1, id1, size1) : LFS_MKTAG(type2, id2, size2))
 
#define LFS_MKATTRS(...)
 
#define LFS_LOCK(cfg)   ((void)cfg, 0)
 Public API wrappers ///. More...
 
#define LFS_UNLOCK(cfg)   ((void)cfg)
 

Typedefs

typedef uint32_t lfs_tag_t
 
typedef int32_t lfs_stag_t
 

Enumerations

enum  { LFS_CMP_EQ = 0, LFS_CMP_LT = 1, LFS_CMP_GT = 2 }
 

Functions

static void lfs_cache_drop (lfs_t *lfs, lfs_cache_t *rcache)
 Caching block device operations ///. More...
 
static void lfs_cache_zero (lfs_t *lfs, lfs_cache_t *pcache)
 
static int lfs_bd_read (lfs_t *lfs, const lfs_cache_t *pcache, lfs_cache_t *rcache, lfs_size_t hint, lfs_block_t block, lfs_off_t off, void *buffer, lfs_size_t size)
 
static int lfs_bd_cmp (lfs_t *lfs, const lfs_cache_t *pcache, lfs_cache_t *rcache, lfs_size_t hint, lfs_block_t block, lfs_off_t off, const void *buffer, lfs_size_t size)
 
static int lfs_bd_flush (lfs_t *lfs, lfs_cache_t *pcache, lfs_cache_t *rcache, bool validate)
 
static int lfs_bd_sync (lfs_t *lfs, lfs_cache_t *pcache, lfs_cache_t *rcache, bool validate)
 
static int lfs_bd_prog (lfs_t *lfs, lfs_cache_t *pcache, lfs_cache_t *rcache, bool validate, lfs_block_t block, lfs_off_t off, const void *buffer, lfs_size_t size)
 
static int lfs_bd_erase (lfs_t *lfs, lfs_block_t block)
 
static void lfs_pair_swap (lfs_block_t pair[2])
 Small type-level utilities ///. More...
 
static bool lfs_pair_isnull (const lfs_block_t pair[2])
 
static int lfs_pair_cmp (const lfs_block_t paira[2], const lfs_block_t pairb[2])
 
static bool lfs_pair_sync (const lfs_block_t paira[2], const lfs_block_t pairb[2])
 
static void lfs_pair_fromle32 (lfs_block_t pair[2])
 
static void lfs_pair_tole32 (lfs_block_t pair[2])
 
static bool lfs_tag_isvalid (lfs_tag_t tag)
 
static bool lfs_tag_isdelete (lfs_tag_t tag)
 
static uint16_t lfs_tag_type1 (lfs_tag_t tag)
 
static uint16_t lfs_tag_type3 (lfs_tag_t tag)
 
static uint8_t lfs_tag_chunk (lfs_tag_t tag)
 
static int8_t lfs_tag_splice (lfs_tag_t tag)
 
static uint16_t lfs_tag_id (lfs_tag_t tag)
 
static lfs_size_t lfs_tag_size (lfs_tag_t tag)
 
static lfs_size_t lfs_tag_dsize (lfs_tag_t tag)
 
static void lfs_gstate_xor (lfs_gstate_t *a, const lfs_gstate_t *b)
 
static bool lfs_gstate_iszero (const lfs_gstate_t *a)
 
static bool lfs_gstate_hasorphans (const lfs_gstate_t *a)
 
static uint8_t lfs_gstate_getorphans (const lfs_gstate_t *a)
 
static bool lfs_gstate_hasmove (const lfs_gstate_t *a)
 
static bool lfs_gstate_hasmovehere (const lfs_gstate_t *a, const lfs_block_t *pair)
 
static void lfs_gstate_fromle32 (lfs_gstate_t *a)
 
static void lfs_gstate_tole32 (lfs_gstate_t *a)
 
static void lfs_ctz_fromle32 (struct lfs_ctz *ctz)
 
static void lfs_ctz_tole32 (struct lfs_ctz *ctz)
 
static void lfs_superblock_fromle32 (lfs_superblock_t *superblock)
 
static void lfs_superblock_tole32 (lfs_superblock_t *superblock)
 
static bool lfs_mlist_isopen (struct lfs_mlist *head, struct lfs_mlist *node)
 
static void lfs_mlist_remove (lfs_t *lfs, struct lfs_mlist *mlist)
 
static void lfs_mlist_append (lfs_t *lfs, struct lfs_mlist *mlist)
 
static int lfs_dir_commit (lfs_t *lfs, lfs_mdir_t *dir, const struct lfs_mattr *attrs, int attrcount)
 Internal operations predeclared here ///. More...
 
static int lfs_dir_compact (lfs_t *lfs, lfs_mdir_t *dir, const struct lfs_mattr *attrs, int attrcount, lfs_mdir_t *source, uint16_t begin, uint16_t end)
 
static lfs_ssize_t lfs_file_rawwrite (lfs_t *lfs, lfs_file_t *file, const void *buffer, lfs_size_t size)
 
static int lfs_file_rawsync (lfs_t *lfs, lfs_file_t *file)
 
static int lfs_file_outline (lfs_t *lfs, lfs_file_t *file)
 
static int lfs_file_flush (lfs_t *lfs, lfs_file_t *file)
 
static int lfs_fs_preporphans (lfs_t *lfs, int8_t orphans)
 
static void lfs_fs_prepmove (lfs_t *lfs, uint16_t id, const lfs_block_t pair[2])
 
static int lfs_fs_pred (lfs_t *lfs, const lfs_block_t dir[2], lfs_mdir_t *pdir)
 
static lfs_stag_t lfs_fs_parent (lfs_t *lfs, const lfs_block_t dir[2], lfs_mdir_t *parent)
 
static int lfs_fs_relocate (lfs_t *lfs, const lfs_block_t oldpair[2], lfs_block_t newpair[2])
 
static int lfs_fs_forceconsistency (lfs_t *lfs)
 
static int lfs_dir_rawrewind (lfs_t *lfs, lfs_dir_t *dir)
 
static lfs_ssize_t lfs_file_rawread (lfs_t *lfs, lfs_file_t *file, void *buffer, lfs_size_t size)
 
static int lfs_file_rawclose (lfs_t *lfs, lfs_file_t *file)
 
static lfs_soff_t lfs_file_rawsize (lfs_t *lfs, lfs_file_t *file)
 
static lfs_ssize_t lfs_fs_rawsize (lfs_t *lfs)
 
static int lfs_fs_rawtraverse (lfs_t *lfs, int(*cb)(void *data, lfs_block_t block), void *data, bool includeorphans)
 Filesystem filesystem operations ///. More...
 
static int lfs_deinit (lfs_t *lfs)
 
static int lfs_rawunmount (lfs_t *lfs)
 
static int lfs_alloc_lookahead (void *p, lfs_block_t block)
 Block allocator ///. More...
 
static void lfs_alloc_ack (lfs_t *lfs)
 
static void lfs_alloc_drop (lfs_t *lfs)
 
static int lfs_alloc (lfs_t *lfs, lfs_block_t *block)
 
static lfs_stag_t lfs_dir_getslice (lfs_t *lfs, const lfs_mdir_t *dir, lfs_tag_t gmask, lfs_tag_t gtag, lfs_off_t goff, void *gbuffer, lfs_size_t gsize)
 Metadata pair and directory operations ///. More...
 
static lfs_stag_t lfs_dir_get (lfs_t *lfs, const lfs_mdir_t *dir, lfs_tag_t gmask, lfs_tag_t gtag, void *buffer)
 
static int lfs_dir_getread (lfs_t *lfs, const lfs_mdir_t *dir, const lfs_cache_t *pcache, lfs_cache_t *rcache, lfs_size_t hint, lfs_tag_t gmask, lfs_tag_t gtag, lfs_off_t off, void *buffer, lfs_size_t size)
 
static int lfs_dir_traverse_filter (void *p, lfs_tag_t tag, const void *buffer)
 
static int lfs_dir_traverse (lfs_t *lfs, const lfs_mdir_t *dir, lfs_off_t off, lfs_tag_t ptag, const struct lfs_mattr *attrs, int attrcount, lfs_tag_t tmask, lfs_tag_t ttag, uint16_t begin, uint16_t end, int16_t diff, int(*cb)(void *data, lfs_tag_t tag, const void *buffer), void *data)
 
static lfs_stag_t lfs_dir_fetchmatch (lfs_t *lfs, lfs_mdir_t *dir, const lfs_block_t pair[2], lfs_tag_t fmask, lfs_tag_t ftag, uint16_t *id, int(*cb)(void *data, lfs_tag_t tag, const void *buffer), void *data)
 
static int lfs_dir_fetch (lfs_t *lfs, lfs_mdir_t *dir, const lfs_block_t pair[2])
 
static int lfs_dir_getgstate (lfs_t *lfs, const lfs_mdir_t *dir, lfs_gstate_t *gstate)
 
static int lfs_dir_getinfo (lfs_t *lfs, lfs_mdir_t *dir, uint16_t id, struct lfs_info *info)
 
static int lfs_dir_find_match (void *data, lfs_tag_t tag, const void *buffer)
 
static lfs_stag_t lfs_dir_find (lfs_t *lfs, lfs_mdir_t *dir, const char **path, uint16_t *id)
 
static int lfs_dir_commitprog (lfs_t *lfs, struct lfs_commit *commit, const void *buffer, lfs_size_t size)
 
static int lfs_dir_commitattr (lfs_t *lfs, struct lfs_commit *commit, lfs_tag_t tag, const void *buffer)
 
static int lfs_dir_commitcrc (lfs_t *lfs, struct lfs_commit *commit)
 
static int lfs_dir_alloc (lfs_t *lfs, lfs_mdir_t *dir)
 
static int lfs_dir_drop (lfs_t *lfs, lfs_mdir_t *dir, lfs_mdir_t *tail)
 
static int lfs_dir_split (lfs_t *lfs, lfs_mdir_t *dir, const struct lfs_mattr *attrs, int attrcount, lfs_mdir_t *source, uint16_t split, uint16_t end)
 
static int lfs_dir_commit_size (void *p, lfs_tag_t tag, const void *buffer)
 
static int lfs_dir_commit_commit (void *p, lfs_tag_t tag, const void *buffer)
 
static int lfs_rawmkdir (lfs_t *lfs, const char *path)
 Top level directory operations ///. More...
 
static int lfs_dir_rawopen (lfs_t *lfs, lfs_dir_t *dir, const char *path)
 
static int lfs_dir_rawclose (lfs_t *lfs, lfs_dir_t *dir)
 
static int lfs_dir_rawread (lfs_t *lfs, lfs_dir_t *dir, struct lfs_info *info)
 
static int lfs_dir_rawseek (lfs_t *lfs, lfs_dir_t *dir, lfs_off_t off)
 
static lfs_soff_t lfs_dir_rawtell (lfs_t *lfs, lfs_dir_t *dir)
 
static int lfs_ctz_index (lfs_t *lfs, lfs_off_t *off)
 File index list operations ///. More...
 
static int lfs_ctz_find (lfs_t *lfs, const lfs_cache_t *pcache, lfs_cache_t *rcache, lfs_block_t head, lfs_size_t size, lfs_size_t pos, lfs_block_t *block, lfs_off_t *off)
 
static int lfs_ctz_extend (lfs_t *lfs, lfs_cache_t *pcache, lfs_cache_t *rcache, lfs_block_t head, lfs_size_t size, lfs_block_t *block, lfs_off_t *off)
 
static int lfs_ctz_traverse (lfs_t *lfs, const lfs_cache_t *pcache, lfs_cache_t *rcache, lfs_block_t head, lfs_size_t size, int(*cb)(void *, lfs_block_t), void *data)
 
static int lfs_file_rawopencfg (lfs_t *lfs, lfs_file_t *file, const char *path, int flags, const struct lfs_file_config *cfg)
 Top level file operations ///. More...
 
static int lfs_file_rawopen (lfs_t *lfs, lfs_file_t *file, const char *path, int flags)
 
static int lfs_file_relocate (lfs_t *lfs, lfs_file_t *file)
 
static lfs_soff_t lfs_file_rawseek (lfs_t *lfs, lfs_file_t *file, lfs_soff_t off, int whence)
 
static int lfs_file_rawtruncate (lfs_t *lfs, lfs_file_t *file, lfs_off_t size)
 
static lfs_soff_t lfs_file_rawtell (lfs_t *lfs, lfs_file_t *file)
 
static int lfs_file_rawrewind (lfs_t *lfs, lfs_file_t *file)
 
static int lfs_rawstat (lfs_t *lfs, const char *path, struct lfs_info *info)
 General fs operations ///. More...
 
static int lfs_rawremove (lfs_t *lfs, const char *path)
 
static int lfs_rawrename (lfs_t *lfs, const char *oldpath, const char *newpath)
 
static lfs_ssize_t lfs_rawgetattr (lfs_t *lfs, const char *path, uint8_t type, void *buffer, lfs_size_t size)
 
static int lfs_commitattr (lfs_t *lfs, const char *path, uint8_t type, const void *buffer, lfs_size_t size)
 
static int lfs_rawsetattr (lfs_t *lfs, const char *path, uint8_t type, const void *buffer, lfs_size_t size)
 
static int lfs_rawremoveattr (lfs_t *lfs, const char *path, uint8_t type)
 
static int lfs_init (lfs_t *lfs, const struct lfs_config *cfg)
 Filesystem operations ///. More...
 
static int lfs_rawformat (lfs_t *lfs, const struct lfs_config *cfg)
 
static int lfs_rawmount (lfs_t *lfs, const struct lfs_config *cfg)
 
static int lfs_fs_parent_match (void *data, lfs_tag_t tag, const void *buffer)
 
static int lfs_fs_demove (lfs_t *lfs)
 
static int lfs_fs_deorphan (lfs_t *lfs)
 
static int lfs_fs_size_count (void *p, lfs_block_t block)
 
int lfs_format (lfs_t *lfs, const struct lfs_config *cfg)
 Filesystem functions ///. More...
 
int lfs_mount (lfs_t *lfs, const struct lfs_config *cfg)
 
int lfs_unmount (lfs_t *lfs)
 
int lfs_remove (lfs_t *lfs, const char *path)
 General operations ///. More...
 
int lfs_rename (lfs_t *lfs, const char *oldpath, const char *newpath)
 
int lfs_stat (lfs_t *lfs, const char *path, struct lfs_info *info)
 
lfs_ssize_t lfs_getattr (lfs_t *lfs, const char *path, uint8_t type, void *buffer, lfs_size_t size)
 
int lfs_setattr (lfs_t *lfs, const char *path, uint8_t type, const void *buffer, lfs_size_t size)
 
int lfs_removeattr (lfs_t *lfs, const char *path, uint8_t type)
 
int lfs_file_open (lfs_t *lfs, lfs_file_t *file, const char *path, int flags)
 File operations ///. More...
 
int lfs_file_opencfg (lfs_t *lfs, lfs_file_t *file, const char *path, int flags, const struct lfs_file_config *cfg)
 
int lfs_file_close (lfs_t *lfs, lfs_file_t *file)
 
int lfs_file_sync (lfs_t *lfs, lfs_file_t *file)
 
lfs_ssize_t lfs_file_read (lfs_t *lfs, lfs_file_t *file, void *buffer, lfs_size_t size)
 
lfs_ssize_t lfs_file_write (lfs_t *lfs, lfs_file_t *file, const void *buffer, lfs_size_t size)
 
lfs_soff_t lfs_file_seek (lfs_t *lfs, lfs_file_t *file, lfs_soff_t off, int whence)
 
int lfs_file_truncate (lfs_t *lfs, lfs_file_t *file, lfs_off_t size)
 
lfs_soff_t lfs_file_tell (lfs_t *lfs, lfs_file_t *file)
 
int lfs_file_rewind (lfs_t *lfs, lfs_file_t *file)
 
lfs_soff_t lfs_file_size (lfs_t *lfs, lfs_file_t *file)
 
int lfs_mkdir (lfs_t *lfs, const char *path)
 Directory operations ///. More...
 
int lfs_dir_open (lfs_t *lfs, lfs_dir_t *dir, const char *path)
 
int lfs_dir_close (lfs_t *lfs, lfs_dir_t *dir)
 
int lfs_dir_read (lfs_t *lfs, lfs_dir_t *dir, struct lfs_info *info)
 
int lfs_dir_seek (lfs_t *lfs, lfs_dir_t *dir, lfs_off_t off)
 
lfs_soff_t lfs_dir_tell (lfs_t *lfs, lfs_dir_t *dir)
 
int lfs_dir_rewind (lfs_t *lfs, lfs_dir_t *dir)
 
lfs_ssize_t lfs_fs_size (lfs_t *lfs)
 Filesystem-level filesystem operations. More...
 
int lfs_fs_traverse (lfs_t *lfs, int(*cb)(void *, lfs_block_t), void *data)
 

Macro Definition Documentation

◆ LFS_BLOCK_INLINE

#define LFS_BLOCK_INLINE   ((lfs_block_t)-2)

◆ LFS_BLOCK_NULL

#define LFS_BLOCK_NULL   ((lfs_block_t)-1)

◆ LFS_LOCK

#define LFS_LOCK (   cfg)    ((void)cfg, 0)

Public API wrappers ///.

◆ LFS_MKATTRS

#define LFS_MKATTRS (   ...)
Value:
(struct lfs_mattr[]){__VA_ARGS__}, \
sizeof((struct lfs_mattr[]){__VA_ARGS__}) / sizeof(struct lfs_mattr)

◆ LFS_MKTAG

#define LFS_MKTAG (   type,
  id,
  size 
)     (((lfs_tag_t)(type) << 20) | ((lfs_tag_t)(id) << 10) | (lfs_tag_t)(size))

◆ LFS_MKTAG_IF

#define LFS_MKTAG_IF (   cond,
  type,
  id,
  size 
)     ((cond) ? LFS_MKTAG(type, id, size) : LFS_MKTAG(LFS_FROM_NOOP, 0, 0))

◆ LFS_MKTAG_IF_ELSE

#define LFS_MKTAG_IF_ELSE (   cond,
  type1,
  id1,
  size1,
  type2,
  id2,
  size2 
)     ((cond) ? LFS_MKTAG(type1, id1, size1) : LFS_MKTAG(type2, id2, size2))

◆ LFS_UNLOCK

#define LFS_UNLOCK (   cfg)    ((void)cfg)

Typedef Documentation

◆ lfs_stag_t

typedef int32_t lfs_stag_t

◆ lfs_tag_t

typedef uint32_t lfs_tag_t

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
LFS_CMP_EQ 
LFS_CMP_LT 
LFS_CMP_GT 

Function Documentation

◆ lfs_alloc()

static int lfs_alloc ( lfs_t lfs,
lfs_block_t block 
)
static

◆ lfs_alloc_ack()

static void lfs_alloc_ack ( lfs_t lfs)
static

◆ lfs_alloc_drop()

static void lfs_alloc_drop ( lfs_t lfs)
static

◆ lfs_alloc_lookahead()

static int lfs_alloc_lookahead ( void *  p,
lfs_block_t  block 
)
static

Block allocator ///.

◆ lfs_bd_cmp()

static int lfs_bd_cmp ( lfs_t lfs,
const lfs_cache_t pcache,
lfs_cache_t rcache,
lfs_size_t  hint,
lfs_block_t  block,
lfs_off_t  off,
const void *  buffer,
lfs_size_t  size 
)
static

◆ lfs_bd_erase()

static int lfs_bd_erase ( lfs_t lfs,
lfs_block_t  block 
)
static

◆ lfs_bd_flush()

static int lfs_bd_flush ( lfs_t lfs,
lfs_cache_t pcache,
lfs_cache_t rcache,
bool  validate 
)
static

◆ lfs_bd_prog()

static int lfs_bd_prog ( lfs_t lfs,
lfs_cache_t pcache,
lfs_cache_t rcache,
bool  validate,
lfs_block_t  block,
lfs_off_t  off,
const void *  buffer,
lfs_size_t  size 
)
static

◆ lfs_bd_read()

static int lfs_bd_read ( lfs_t lfs,
const lfs_cache_t pcache,
lfs_cache_t rcache,
lfs_size_t  hint,
lfs_block_t  block,
lfs_off_t  off,
void *  buffer,
lfs_size_t  size 
)
static

◆ lfs_bd_sync()

static int lfs_bd_sync ( lfs_t lfs,
lfs_cache_t pcache,
lfs_cache_t rcache,
bool  validate 
)
static

◆ lfs_cache_drop()

static void lfs_cache_drop ( lfs_t lfs,
lfs_cache_t rcache 
)
inlinestatic

Caching block device operations ///.

◆ lfs_cache_zero()

static void lfs_cache_zero ( lfs_t lfs,
lfs_cache_t pcache 
)
inlinestatic

◆ lfs_commitattr()

static int lfs_commitattr ( lfs_t lfs,
const char *  path,
uint8_t  type,
const void *  buffer,
lfs_size_t  size 
)
static

◆ lfs_ctz_extend()

static int lfs_ctz_extend ( lfs_t lfs,
lfs_cache_t pcache,
lfs_cache_t rcache,
lfs_block_t  head,
lfs_size_t  size,
lfs_block_t block,
lfs_off_t off 
)
static

◆ lfs_ctz_find()

static int lfs_ctz_find ( lfs_t lfs,
const lfs_cache_t pcache,
lfs_cache_t rcache,
lfs_block_t  head,
lfs_size_t  size,
lfs_size_t  pos,
lfs_block_t block,
lfs_off_t off 
)
static

◆ lfs_ctz_fromle32()

static void lfs_ctz_fromle32 ( struct lfs_ctz ctz)
static

◆ lfs_ctz_index()

static int lfs_ctz_index ( lfs_t lfs,
lfs_off_t off 
)
static

File index list operations ///.

◆ lfs_ctz_tole32()

static void lfs_ctz_tole32 ( struct lfs_ctz ctz)
static

◆ lfs_ctz_traverse()

static int lfs_ctz_traverse ( lfs_t lfs,
const lfs_cache_t pcache,
lfs_cache_t rcache,
lfs_block_t  head,
lfs_size_t  size,
int(*)(void *, lfs_block_t cb,
void *  data 
)
static

◆ lfs_deinit()

static int lfs_deinit ( lfs_t lfs)
static

◆ lfs_dir_alloc()

static int lfs_dir_alloc ( lfs_t lfs,
lfs_mdir_t dir 
)
static

◆ lfs_dir_close()

int lfs_dir_close ( lfs_t lfs,
lfs_dir_t dir 
)

◆ lfs_dir_commit()

static int lfs_dir_commit ( lfs_t lfs,
lfs_mdir_t dir,
const struct lfs_mattr attrs,
int  attrcount 
)
static

Internal operations predeclared here ///.

◆ lfs_dir_commit_commit()

static int lfs_dir_commit_commit ( void *  p,
lfs_tag_t  tag,
const void *  buffer 
)
static

◆ lfs_dir_commit_size()

static int lfs_dir_commit_size ( void *  p,
lfs_tag_t  tag,
const void *  buffer 
)
static

◆ lfs_dir_commitattr()

static int lfs_dir_commitattr ( lfs_t lfs,
struct lfs_commit commit,
lfs_tag_t  tag,
const void *  buffer 
)
static

◆ lfs_dir_commitcrc()

static int lfs_dir_commitcrc ( lfs_t lfs,
struct lfs_commit commit 
)
static

◆ lfs_dir_commitprog()

static int lfs_dir_commitprog ( lfs_t lfs,
struct lfs_commit commit,
const void *  buffer,
lfs_size_t  size 
)
static

◆ lfs_dir_compact()

static int lfs_dir_compact ( lfs_t lfs,
lfs_mdir_t dir,
const struct lfs_mattr attrs,
int  attrcount,
lfs_mdir_t source,
uint16_t  begin,
uint16_t  end 
)
static

◆ lfs_dir_drop()

static int lfs_dir_drop ( lfs_t lfs,
lfs_mdir_t dir,
lfs_mdir_t tail 
)
static

◆ lfs_dir_fetch()

static int lfs_dir_fetch ( lfs_t lfs,
lfs_mdir_t dir,
const lfs_block_t  pair[2] 
)
static

◆ lfs_dir_fetchmatch()

static lfs_stag_t lfs_dir_fetchmatch ( lfs_t lfs,
lfs_mdir_t dir,
const lfs_block_t  pair[2],
lfs_tag_t  fmask,
lfs_tag_t  ftag,
uint16_t *  id,
int(*)(void *data, lfs_tag_t tag, const void *buffer)  cb,
void *  data 
)
static

◆ lfs_dir_find()

static lfs_stag_t lfs_dir_find ( lfs_t lfs,
lfs_mdir_t dir,
const char **  path,
uint16_t *  id 
)
static

◆ lfs_dir_find_match()

static int lfs_dir_find_match ( void *  data,
lfs_tag_t  tag,
const void *  buffer 
)
static

◆ lfs_dir_get()

static lfs_stag_t lfs_dir_get ( lfs_t lfs,
const lfs_mdir_t dir,
lfs_tag_t  gmask,
lfs_tag_t  gtag,
void *  buffer 
)
static

◆ lfs_dir_getgstate()

static int lfs_dir_getgstate ( lfs_t lfs,
const lfs_mdir_t dir,
lfs_gstate_t gstate 
)
static

◆ lfs_dir_getinfo()

static int lfs_dir_getinfo ( lfs_t lfs,
lfs_mdir_t dir,
uint16_t  id,
struct lfs_info info 
)
static

◆ lfs_dir_getread()

static int lfs_dir_getread ( lfs_t lfs,
const lfs_mdir_t dir,
const lfs_cache_t pcache,
lfs_cache_t rcache,
lfs_size_t  hint,
lfs_tag_t  gmask,
lfs_tag_t  gtag,
lfs_off_t  off,
void *  buffer,
lfs_size_t  size 
)
static

◆ lfs_dir_getslice()

static lfs_stag_t lfs_dir_getslice ( lfs_t lfs,
const lfs_mdir_t dir,
lfs_tag_t  gmask,
lfs_tag_t  gtag,
lfs_off_t  goff,
void *  gbuffer,
lfs_size_t  gsize 
)
static

Metadata pair and directory operations ///.

◆ lfs_dir_open()

int lfs_dir_open ( lfs_t lfs,
lfs_dir_t dir,
const char *  path 
)

◆ lfs_dir_rawclose()

static int lfs_dir_rawclose ( lfs_t lfs,
lfs_dir_t dir 
)
static

◆ lfs_dir_rawopen()

static int lfs_dir_rawopen ( lfs_t lfs,
lfs_dir_t dir,
const char *  path 
)
static

◆ lfs_dir_rawread()

static int lfs_dir_rawread ( lfs_t lfs,
lfs_dir_t dir,
struct lfs_info info 
)
static

◆ lfs_dir_rawrewind()

static int lfs_dir_rawrewind ( lfs_t lfs,
lfs_dir_t dir 
)
static

◆ lfs_dir_rawseek()

static int lfs_dir_rawseek ( lfs_t lfs,
lfs_dir_t dir,
lfs_off_t  off 
)
static

◆ lfs_dir_rawtell()

static lfs_soff_t lfs_dir_rawtell ( lfs_t lfs,
lfs_dir_t dir 
)
static

◆ lfs_dir_read()

int lfs_dir_read ( lfs_t lfs,
lfs_dir_t dir,
struct lfs_info info 
)

◆ lfs_dir_rewind()

int lfs_dir_rewind ( lfs_t lfs,
lfs_dir_t dir 
)

◆ lfs_dir_seek()

int lfs_dir_seek ( lfs_t lfs,
lfs_dir_t dir,
lfs_off_t  off 
)

◆ lfs_dir_split()

static int lfs_dir_split ( lfs_t lfs,
lfs_mdir_t dir,
const struct lfs_mattr attrs,
int  attrcount,
lfs_mdir_t source,
uint16_t  split,
uint16_t  end 
)
static

◆ lfs_dir_tell()

lfs_soff_t lfs_dir_tell ( lfs_t lfs,
lfs_dir_t dir 
)

◆ lfs_dir_traverse()

static int lfs_dir_traverse ( lfs_t lfs,
const lfs_mdir_t dir,
lfs_off_t  off,
lfs_tag_t  ptag,
const struct lfs_mattr attrs,
int  attrcount,
lfs_tag_t  tmask,
lfs_tag_t  ttag,
uint16_t  begin,
uint16_t  end,
int16_t  diff,
int(*)(void *data, lfs_tag_t tag, const void *buffer)  cb,
void *  data 
)
static

◆ lfs_dir_traverse_filter()

static int lfs_dir_traverse_filter ( void *  p,
lfs_tag_t  tag,
const void *  buffer 
)
static

◆ lfs_file_close()

int lfs_file_close ( lfs_t lfs,
lfs_file_t file 
)

◆ lfs_file_flush()

static int lfs_file_flush ( lfs_t lfs,
lfs_file_t file 
)
static

◆ lfs_file_open()

int lfs_file_open ( lfs_t lfs,
lfs_file_t file,
const char *  path,
int  flags 
)

File operations ///.

◆ lfs_file_opencfg()

int lfs_file_opencfg ( lfs_t lfs,
lfs_file_t file,
const char *  path,
int  flags,
const struct lfs_file_config cfg 
)

◆ lfs_file_outline()

static int lfs_file_outline ( lfs_t lfs,
lfs_file_t file 
)
static

◆ lfs_file_rawclose()

static int lfs_file_rawclose ( lfs_t lfs,
lfs_file_t file 
)
static

◆ lfs_file_rawopen()

static int lfs_file_rawopen ( lfs_t lfs,
lfs_file_t file,
const char *  path,
int  flags 
)
static

◆ lfs_file_rawopencfg()

static int lfs_file_rawopencfg ( lfs_t lfs,
lfs_file_t file,
const char *  path,
int  flags,
const struct lfs_file_config cfg 
)
static

Top level file operations ///.

◆ lfs_file_rawread()

static lfs_ssize_t lfs_file_rawread ( lfs_t lfs,
lfs_file_t file,
void *  buffer,
lfs_size_t  size 
)
static

◆ lfs_file_rawrewind()

static int lfs_file_rawrewind ( lfs_t lfs,
lfs_file_t file 
)
static

◆ lfs_file_rawseek()

static lfs_soff_t lfs_file_rawseek ( lfs_t lfs,
lfs_file_t file,
lfs_soff_t  off,
int  whence 
)
static

◆ lfs_file_rawsize()

static lfs_soff_t lfs_file_rawsize ( lfs_t lfs,
lfs_file_t file 
)
static

◆ lfs_file_rawsync()

static int lfs_file_rawsync ( lfs_t lfs,
lfs_file_t file 
)
static

◆ lfs_file_rawtell()

static lfs_soff_t lfs_file_rawtell ( lfs_t lfs,
lfs_file_t file 
)
static

◆ lfs_file_rawtruncate()

static int lfs_file_rawtruncate ( lfs_t lfs,
lfs_file_t file,
lfs_off_t  size 
)
static

◆ lfs_file_rawwrite()

static lfs_ssize_t lfs_file_rawwrite ( lfs_t lfs,
lfs_file_t file,
const void *  buffer,
lfs_size_t  size 
)
static

◆ lfs_file_read()

lfs_ssize_t lfs_file_read ( lfs_t lfs,
lfs_file_t file,
void *  buffer,
lfs_size_t  size 
)

◆ lfs_file_relocate()

static int lfs_file_relocate ( lfs_t lfs,
lfs_file_t file 
)
static

◆ lfs_file_rewind()

int lfs_file_rewind ( lfs_t lfs,
lfs_file_t file 
)

◆ lfs_file_seek()

lfs_soff_t lfs_file_seek ( lfs_t lfs,
lfs_file_t file,
lfs_soff_t  off,
int  whence 
)

◆ lfs_file_size()

lfs_soff_t lfs_file_size ( lfs_t lfs,
lfs_file_t file 
)

◆ lfs_file_sync()

int lfs_file_sync ( lfs_t lfs,
lfs_file_t file 
)

◆ lfs_file_tell()

lfs_soff_t lfs_file_tell ( lfs_t lfs,
lfs_file_t file 
)

◆ lfs_file_truncate()

int lfs_file_truncate ( lfs_t lfs,
lfs_file_t file,
lfs_off_t  size 
)

◆ lfs_file_write()

lfs_ssize_t lfs_file_write ( lfs_t lfs,
lfs_file_t file,
const void *  buffer,
lfs_size_t  size 
)

◆ lfs_format()

int lfs_format ( lfs_t lfs,
const struct lfs_config cfg 
)

Filesystem functions ///.

◆ lfs_fs_demove()

static int lfs_fs_demove ( lfs_t lfs)
static

◆ lfs_fs_deorphan()

static int lfs_fs_deorphan ( lfs_t lfs)
static

◆ lfs_fs_forceconsistency()

static int lfs_fs_forceconsistency ( lfs_t lfs)
static

◆ lfs_fs_parent()

static lfs_stag_t lfs_fs_parent ( lfs_t lfs,
const lfs_block_t  dir[2],
lfs_mdir_t parent 
)
static

◆ lfs_fs_parent_match()

static int lfs_fs_parent_match ( void *  data,
lfs_tag_t  tag,
const void *  buffer 
)
static

◆ lfs_fs_pred()

static int lfs_fs_pred ( lfs_t lfs,
const lfs_block_t  dir[2],
lfs_mdir_t pdir 
)
static

◆ lfs_fs_prepmove()

static void lfs_fs_prepmove ( lfs_t lfs,
uint16_t  id,
const lfs_block_t  pair[2] 
)
static

◆ lfs_fs_preporphans()

static int lfs_fs_preporphans ( lfs_t lfs,
int8_t  orphans 
)
static

◆ lfs_fs_rawsize()

static lfs_ssize_t lfs_fs_rawsize ( lfs_t lfs)
static

◆ lfs_fs_rawtraverse()

int lfs_fs_rawtraverse ( lfs_t lfs,
int(*)(void *data, lfs_block_t block)  cb,
void *  data,
bool  includeorphans 
)
static

Filesystem filesystem operations ///.

◆ lfs_fs_relocate()

static int lfs_fs_relocate ( lfs_t lfs,
const lfs_block_t  oldpair[2],
lfs_block_t  newpair[2] 
)
static

◆ lfs_fs_size()

lfs_ssize_t lfs_fs_size ( lfs_t lfs)

Filesystem-level filesystem operations.

◆ lfs_fs_size_count()

static int lfs_fs_size_count ( void *  p,
lfs_block_t  block 
)
static

◆ lfs_fs_traverse()

int lfs_fs_traverse ( lfs_t lfs,
int(*)(void *, lfs_block_t cb,
void *  data 
)

◆ lfs_getattr()

lfs_ssize_t lfs_getattr ( lfs_t lfs,
const char *  path,
uint8_t  type,
void *  buffer,
lfs_size_t  size 
)

◆ lfs_gstate_fromle32()

static void lfs_gstate_fromle32 ( lfs_gstate_t a)
inlinestatic

◆ lfs_gstate_getorphans()

static uint8_t lfs_gstate_getorphans ( const lfs_gstate_t a)
inlinestatic

◆ lfs_gstate_hasmove()

static bool lfs_gstate_hasmove ( const lfs_gstate_t a)
inlinestatic

◆ lfs_gstate_hasmovehere()

static bool lfs_gstate_hasmovehere ( const lfs_gstate_t a,
const lfs_block_t pair 
)
inlinestatic

◆ lfs_gstate_hasorphans()

static bool lfs_gstate_hasorphans ( const lfs_gstate_t a)
inlinestatic

◆ lfs_gstate_iszero()

static bool lfs_gstate_iszero ( const lfs_gstate_t a)
inlinestatic

◆ lfs_gstate_tole32()

static void lfs_gstate_tole32 ( lfs_gstate_t a)
inlinestatic

◆ lfs_gstate_xor()

static void lfs_gstate_xor ( lfs_gstate_t a,
const lfs_gstate_t b 
)
inlinestatic

◆ lfs_init()

static int lfs_init ( lfs_t lfs,
const struct lfs_config cfg 
)
static

Filesystem operations ///.

◆ lfs_mkdir()

int lfs_mkdir ( lfs_t lfs,
const char *  path 
)

Directory operations ///.

◆ lfs_mlist_append()

static void lfs_mlist_append ( lfs_t lfs,
struct lfs_mlist *  mlist 
)
static

◆ lfs_mlist_isopen()

static bool lfs_mlist_isopen ( struct lfs_mlist *  head,
struct lfs_mlist *  node 
)
static

◆ lfs_mlist_remove()

static void lfs_mlist_remove ( lfs_t lfs,
struct lfs_mlist *  mlist 
)
static

◆ lfs_mount()

int lfs_mount ( lfs_t lfs,
const struct lfs_config cfg 
)

◆ lfs_pair_cmp()

static int lfs_pair_cmp ( const lfs_block_t  paira[2],
const lfs_block_t  pairb[2] 
)
inlinestatic

◆ lfs_pair_fromle32()

static void lfs_pair_fromle32 ( lfs_block_t  pair[2])
inlinestatic

◆ lfs_pair_isnull()

static bool lfs_pair_isnull ( const lfs_block_t  pair[2])
inlinestatic

◆ lfs_pair_swap()

static void lfs_pair_swap ( lfs_block_t  pair[2])
inlinestatic

Small type-level utilities ///.

◆ lfs_pair_sync()

static bool lfs_pair_sync ( const lfs_block_t  paira[2],
const lfs_block_t  pairb[2] 
)
inlinestatic

◆ lfs_pair_tole32()

static void lfs_pair_tole32 ( lfs_block_t  pair[2])
inlinestatic

◆ lfs_rawformat()

static int lfs_rawformat ( lfs_t lfs,
const struct lfs_config cfg 
)
static

◆ lfs_rawgetattr()

static lfs_ssize_t lfs_rawgetattr ( lfs_t lfs,
const char *  path,
uint8_t  type,
void *  buffer,
lfs_size_t  size 
)
static

◆ lfs_rawmkdir()

static int lfs_rawmkdir ( lfs_t lfs,
const char *  path 
)
static

Top level directory operations ///.

◆ lfs_rawmount()

static int lfs_rawmount ( lfs_t lfs,
const struct lfs_config cfg 
)
static

◆ lfs_rawremove()

static int lfs_rawremove ( lfs_t lfs,
const char *  path 
)
static

◆ lfs_rawremoveattr()

static int lfs_rawremoveattr ( lfs_t lfs,
const char *  path,
uint8_t  type 
)
static

◆ lfs_rawrename()

static int lfs_rawrename ( lfs_t lfs,
const char *  oldpath,
const char *  newpath 
)
static

◆ lfs_rawsetattr()

static int lfs_rawsetattr ( lfs_t lfs,
const char *  path,
uint8_t  type,
const void *  buffer,
lfs_size_t  size 
)
static

◆ lfs_rawstat()

static int lfs_rawstat ( lfs_t lfs,
const char *  path,
struct lfs_info info 
)
static

General fs operations ///.

◆ lfs_rawunmount()

static int lfs_rawunmount ( lfs_t lfs)
static

◆ lfs_remove()

int lfs_remove ( lfs_t lfs,
const char *  path 
)

General operations ///.

◆ lfs_removeattr()

int lfs_removeattr ( lfs_t lfs,
const char *  path,
uint8_t  type 
)

◆ lfs_rename()

int lfs_rename ( lfs_t lfs,
const char *  oldpath,
const char *  newpath 
)

◆ lfs_setattr()

int lfs_setattr ( lfs_t lfs,
const char *  path,
uint8_t  type,
const void *  buffer,
lfs_size_t  size 
)

◆ lfs_stat()

int lfs_stat ( lfs_t lfs,
const char *  path,
struct lfs_info info 
)

◆ lfs_superblock_fromle32()

static void lfs_superblock_fromle32 ( lfs_superblock_t superblock)
inlinestatic

◆ lfs_superblock_tole32()

static void lfs_superblock_tole32 ( lfs_superblock_t superblock)
inlinestatic

◆ lfs_tag_chunk()

static uint8_t lfs_tag_chunk ( lfs_tag_t  tag)
inlinestatic

◆ lfs_tag_dsize()

static lfs_size_t lfs_tag_dsize ( lfs_tag_t  tag)
inlinestatic

◆ lfs_tag_id()

static uint16_t lfs_tag_id ( lfs_tag_t  tag)
inlinestatic

◆ lfs_tag_isdelete()

static bool lfs_tag_isdelete ( lfs_tag_t  tag)
inlinestatic

◆ lfs_tag_isvalid()

static bool lfs_tag_isvalid ( lfs_tag_t  tag)
inlinestatic

◆ lfs_tag_size()

static lfs_size_t lfs_tag_size ( lfs_tag_t  tag)
inlinestatic

◆ lfs_tag_splice()

static int8_t lfs_tag_splice ( lfs_tag_t  tag)
inlinestatic

◆ lfs_tag_type1()

static uint16_t lfs_tag_type1 ( lfs_tag_t  tag)
inlinestatic

◆ lfs_tag_type3()

static uint16_t lfs_tag_type3 ( lfs_tag_t  tag)
inlinestatic

◆ lfs_unmount()

int lfs_unmount ( lfs_t lfs)
lfs_mattr
Definition: lfs.c:338